我很确定我的问题与脚本参考有关。
我已将它添加到我的捆绑包中
bundles.Add(new ScriptBundle("~/bundles/bootstrap-select").Include(
"~/Scripts/bootstrap-select.js",
"~/Scripts/bootstrap-select.min.js"));
这是我的意见代码:
<script type="text/javascript">
$(document).ready(function () {
$('.selectpicker').selectpicker({
liveSearch: true,
showSubtext: true
});
});
html格式:
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.SagId, "SagId", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(x => x.SagId,(IEnumerable<SelectListItem>)ViewBag.SagId,
new
{
@class = "form-control selectpicker",
data_show_subtext = "true",
data_live_search = "true"
})
@Html.ValidationMessageFor(model => model.SagId, "", new { @class = "text-danger" })
</div>
</div>
我从我的视图包中得到了列表,效果很好。但我似乎无法解决这个问题。
更新:尝试在视图中手动添加引用。现在保管箱完全消失了,我得到了这些错误:
Uncaught TypeError: Cannot read property 'valHooks' of undefined
at bootstrap-select.min.js:7
at bootstrap-select.min.js:8
at bootstrap-select.min.js:7
at bootstrap-select.min.js:7
Create:78 Uncaught ReferenceError: $ is not defined at Create:78