引导选择DropDownList不显示
Bootstrap-select DropDownList not showing
我有一个引导选择组合框,我在ajax调用中用数据填充它Html:
<div class="row">
<select id="selectGemeente1" class="selectpicker" data-live-search="true"></select>
</div>
Ajax调用:
var gemeenteLijst = [];
var GetGemeentes = function () {
$.ajax({
type: "GET",
dataType: "json",
url: 'https://localhost::blabla',
contentType: "application/json; charset=utf-8",
success: function (data) {
var test = document.getElementById("selectGemeente1");
data.forEach(function (item) {
var opt = document.createElement("option");
opt.value = item.GemeenteId;
opt.innerHTML = item.Naam;
test.appendChild(opt);
});
},
error: function (xhr, status, error) {
alert(xhr.responseText);
}
});
}
$(document).ready(function () {
GetGemeentes();
})
运行我的应用程序后,我的选择被填充,但下拉列表没有打开。。
html运行后
我已经看到很多解决方案说,我应该把这个放在我的$(文档).准备
$(".selectpicker").html(optgroup);
但是我收到一个错误,selectpicker不是一个函数。
gemeenteLijstLaden.js:36 Uncaught TypeError: $(...).selectpicker is not a function
我已经实现了这些脚本文件
<script src="~/Scripts/jquery-2.2.3.min.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/i18n/defaults-nl_NL.min.js"></script>
<script src="~/Scripts/myCharts/gemeenteLijstLaden.js"></script>
我找到了一个解决方案。我只需要刷新我选择的
$('.selectpicker').selectpicker('refresh');
success: function (data) {
var selectGemeent = $("#selectGemeente1");
selectGemeent.empty();
$('#selectGemeente1').append($("<option></option>").
attr("value", "0").
text("Select"));
$.each(data.forEach, function (index, item) {
selectGemeent.append($('<option>', {
value: item.GemeenteId,
text: item.Naam
})); ////function
});
},
在ajax成功中使用它,并在文本和值之后添加其他文件
相关文章:
- 从桌面读取python文件时高亮显示代码
- 使用JS如何动态更改显示的html文件中的文本背景颜色
- 如何在生成下载文件时显示加载动画
- React重新渲染但未显示正确的组件
- nodejs-expressjs上传图像并显示它们
- 使用JSP从服务器检索和显示图像
- 音频控件在mouseover上显示,在mouseout上淡出
- 让文本输入幻灯片显示输入时的新文本输入?然后向后滑动
- 使用电话间隙在Android应用程序中显示SQL Lite的数据
- 显示5秒后隐藏潜水
- 画廊图像未显示
- 不显示带有本地json文件数据的谷歌地图脚本
- 如何将json数据显示为html
- 引导选择DropDownList不显示
- 如何在不使用javascript和asp.net选择dropdownlist值的情况下显示验证
- Kendo UI Web-DropDownList中显示为'未定义'
- Dropdownlist Onchange显示其他Dropdownlist
- 有没有办法防止DropDownList在JavaScript中单击时显示列表项
- 选择Dropdownlist选项时在文本框上显示值
- 将鼠标悬停在DropDownList项目ASP.NET上时显示图片