modal select2不显示
你好,modal里面你用过select2控件么?为啥数据查出来了,填充不进去呢?普通页面没问题的,我的方法如下:
function BindSelect(ctrlName, url) {
alert('in');
var control = $('#' + ctrlName);
//设置Select2的处理
control.select2({
allowClear: false,
/* templateResult: templateResult,
templateSelection: templateSelection,*/
escapeMarkup: function (m) {
return m;
}
});
//绑定Ajax的内容
$.getJSON(url, function (data) {
control.empty();//清空下拉框
$.each(data.items, function (i, item) {
control.append("<option value='" + item.id + "'> " + item.name + "</option>");
});
control.append("<option value='0' selected='selected'> 所有</option>");
});
control.select2("val", 0);
}
function BindSelect(ctrlName, url) {
alert('in');
var control = $('#' + ctrlName);
//设置Select2的处理
control.select2({
allowClear: false,
/* templateResult: templateResult,
templateSelection: templateSelection,*/
escapeMarkup: function (m) {
return m;
}
});
//绑定Ajax的内容
$.getJSON(url, function (data) {
control.empty();//清空下拉框
$.each(data.items, function (i, item) {
control.append("<option value='" + item.id + "'> " + item.name + "</option>");
});
control.append("<option value='0' selected='selected'> 所有</option>");
});
control.select2("val", 0);
}
1 个回复
rew1011
赞同来自: