如何正确实现Jquery多选小部件

How to correctly implement Jquery MultiSelect Widget?

本文关键字:小部 Jquery 何正确 实现      更新时间:2023-09-26

我正在尝试在ASP.NET MVC Razor视图中使用Jquery Multiselect。我使用这个网站作为参考。

http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/filter.htm

我已添加

jquery.multiselect.filter.js

 jquery.multiselect.filter.css

就像它告诉你做的那样。然后我试着放置他们显示的1行来创建过滤器。

$("select").multiselect().multiselectfilter();

这完成了工作,并在开发者工具控制台窗口上给了我以下2个错误:

jquery.multiselect.filter.js:19 Uncaught TypeError: $.widget is not a function //In the Javascript file they provide
Index:356 Uncaught TypeError: $(...).multiselect is not a function//In my Section Scripts

下面是我的脚本部分,在我的剃刀视图的底部,我正在努力实现这一点。

@section scripts
{
<link href="@Url.Content("~/Content/jquery.multiselect.filter.css")"    rel="stylesheet" type="text/css" />
<script type="text/javascript" src="@Url.Content("/Scripts/jquery.multiselect.filter.js")"></script>
<script>
    $(document).ready(function () {
        $("select").multiselect().multiselectfilter();
   });
</script>
}

使用过这个工具的人能告诉我我做错了什么吗?

multiselect源代码的第8行,有

 * Depends:
 *   - jQuery UI MultiSelect widget

您可以在加载多选代码之前加载jQuery ui