Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript MVC 4将所选插件添加到Html.DropdownListFor_Javascript_Jquery_Asp.net Mvc 4_Jquery Chosen_Html.dropdownlistfor - Fatal编程技术网

Javascript MVC 4将所选插件添加到Html.DropdownListFor

Javascript MVC 4将所选插件添加到Html.DropdownListFor,javascript,jquery,asp.net-mvc-4,jquery-chosen,html.dropdownlistfor,Javascript,Jquery,Asp.net Mvc 4,Jquery Chosen,Html.dropdownlistfor,我需要一些帮助。在我的应用程序中,我会有下拉列表,有些会有很多选择。所以我决定尝试一下所选的插件。我需要一些帮助来设置它 目前,我在脚本/内容目录中选择了.jquery.js和.css,选择了.jquery.min.js和.css。我需要其他人吗 我把它们放在我的bundle配置中,并放在我的视图中 “视图”下拉列表和“文档准备就绪” @Html.DropDownListFor(model => model.Title, @ViewBag.CourseList as Sele

我需要一些帮助。在我的应用程序中,我会有下拉列表,有些会有很多选择。所以我决定尝试一下所选的插件。我需要一些帮助来设置它

  • 目前,我在脚本/内容目录中选择了.jquery.js和.css,选择了.jquery.min.js和.css。我需要其他人吗

  • 我把它们放在我的bundle配置中,并放在我的视图中

“视图”下拉列表和“文档准备就绪”

@Html.DropDownListFor(model => model.Title,
    @ViewBag.CourseList as SelectList, " -- Select Course -- ", new { @class = "chzn-select" })
@Html.ValidationMessageFor(model => model.Title)
...
...
<script type="text/javascript">
    $(document).ready(function () {
        $('.chzn-select').chosen();
    });
...
</script>
@Html.DropDownListFor(model=>model.Title,
@ViewBag.CourseList为SelectList,“--选择课程--”,新建{@class=“chzn Select”})
@Html.ValidationMessageFor(model=>model.Title)
...
...
$(文档).ready(函数(){
$('.chzn select').selected();
});
...
当前获取未捕获的引用错误:$未在我的$(文档)上定义

我还缺什么


另外,如果您需要更多,请告诉我。

好的。因此,在浏览网络后,我发现我的脚本没有被创建。然后我有一些打字错误。哇。对简单的错误感到如此沮丧


感谢@Hackerman提供网络

您是否在
\u Layout.cshtml
文件中包含jquery,可能存在版本冲突该错误将表明未正确加载普通的旧jquery。确保捆绑包设置正确,并在浏览器中检查加载的页面以确保jquery正在加载。您是否刚刚检查了“网络”选项卡上的捆绑包文件是否正在页面中加载?我已将捆绑包呈现在
\u Layout.cshtml
中,它们当前位于
@section Scripts{}
在底部。他们应该在别的地方吗?他们好像没有上膛
@Html.DropDownListFor(model => model.Title,
    @ViewBag.CourseList as SelectList, " -- Select Course -- ", new { @class = "chzn-select" })
@Html.ValidationMessageFor(model => model.Title)
...
...
<script type="text/javascript">
    $(document).ready(function () {
        $('.chzn-select').chosen();
    });
...
</script>