JQuery MultiSelect下拉列表不工作
我在MVC5应用程序中使用Eric hynds mutiselect下拉列表。我在select2上使用这个JQuery插件,因为它支持复选框和我需要的一些其他功能。我的解决方案参考了以下javascrip&css文件 jquery-2.1.3.js是使用bundle添加的JQuery MultiSelect下拉列表不工作,jquery,asp.net-mvc,jquery-multiselect,kendo-multiselect,Jquery,Asp.net Mvc,Jquery Multiselect,Kendo Multiselect,我在MVC5应用程序中使用Eric hynds mutiselect下拉列表。我在select2上使用这个JQuery插件,因为它支持复选框和我需要的一些其他功能。我的解决方案参考了以下javascrip&css文件 jquery-2.1.3.js是使用bundle添加的 bundles.Add(new ScriptBundle("~/bundles/jquery") .Include("~/Scripts/jquery-{version}.js")); <link href="~
bundles.Add(new ScriptBundle("~/bundles/jquery")
.Include("~/Scripts/jquery-{version}.js"));
<link href="~/Content/jquery.multiselect.css" rel="stylesheet" />
<script src="~/Scripts/jquery.multiselect.min.js"></script>
编辑
我在VS中创建了新的空应用程序,并包含了简单的HTML页面。我仍然会犯同样的错误
中第20行第22列的未处理异常
0x800a01b6-JavaScript运行时错误:对象不支持属性
或方法“widget”
下面是完整的html页面
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="Content/jquery.multiselect.css" rel="stylesheet" />
<script src="Scripts/jquery-1.11.2.js"></script>
<script src="Scripts/jquery.multiselect.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function () {$("#mSel").multiple({selectedText: "# of #"});});
</script>
<div>
<select multiple id="mSel">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
</div>
</body>
您需要确保多次包含jquery库。是否可以发布已编译的HTML代码?视图中的捆绑包包括在哪里?如果使用普通模板,它将位于页面底部,但multiselect.js文件似乎位于页面顶部,从而导致该错误。确保multiselect.js位于jquery.jquery之后。jquery作为捆绑包的一部分添加,该捆绑包包含在AppStart中的BundleConfig.cs中。并且multiselect.js在页面上被引用,它本身就是multiselect兼容JQuery2?@user3862378的,同样,您在视图中的哪个位置包含了包?您的视图应该有@Scripts.Render~/bundles/jquery,然后需要包含其他脚本。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="Content/jquery.multiselect.css" rel="stylesheet" />
<script src="Scripts/jquery-1.11.2.js"></script>
<script src="Scripts/jquery.multiselect.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function () {$("#mSel").multiple({selectedText: "# of #"});});
</script>
<div>
<select multiple id="mSel">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
</div>
</body>