[英]Bootstrap multiselect not populating
I have a bootstrap multiselect dropdown box which gets populated through AJAX. 我有一个引导多选下拉框,它通过AJAX填充。 While I am getting the value from the AJAX I am not able to populate the multiselect dropdown.
当我从AJAX获得价值时,我无法填充multiselect下拉列表。 I have another normal dropdown which uses the same AJAX function and it gets populated.
我还有另一个正常的下拉菜单,它使用相同的AJAX函数,并且已填充。 Am I missing something?
我想念什么吗?
I did check this link which did not work for me Adding form elements dynamically to Bootstrap multiselect library 我确实检查了此链接,该链接对我不起作用。 将链接动态添加到Bootstrap multiselect库中
This is the HTML 这是HTML
var lstValue = "";
<select id='sellstValue" + obj.id + "' class='lstvalue' hidden='hidden'>" + lstValue + "</select>
This is my AJAX code 这是我的AJAX代码
var lstvalue = $('#' + rowId).find('.lstvalue').prop('id');
$.ajax({
cache: false,
url: '@Url.Action("PopulateDropdown", "AdvancedSearch")',
type: "POST",
data: { Field: field }
}).done(function (data) {
console.log(data.value)
var listb = $('#' + lstvalue);
listb.empty();
$.each(data.value, function (index, value) {
listb.append($('<option>', {
value: value,
text: value
}, '<option/>'))
});
console.log($('#' + lstvalue))
});
$('#' + lstvalue).attr('multiple', 'multiple');
$('#' + lstvalue).multiselect();
I checked the console output of console.log($('#' + lstvalue)) which gives me the expected result. 我检查了console.log($('#'+ lstvalue))的控制台输出,它提供了预期的结果。
我不确定为什么这行得通,但是在我的AJAX调用中添加'async:false'可以帮助解决它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.