0
我正在使用奏鸣曲管理包来构建管理员仪表板。我想将一些数据绑定到select2增强选择框。是否可以在初始化后改变select2对象?
的问题是,我不能改变页面加载后,选择2属性:
$(function(){
$("#select-brand").select2({
placeholder: "Select report type",
allowClear: true,
data: [{id: 0, text: 'story'},{id: 1, text: 'bug'},{id: 2, text: 'task'}]
});
}):
这会产生错误:
Uncaught Error: Option 'data' is not allowed for Select2 when attached to a <select> element.
但是,即使只是试图覆盖占位符不具有任何影响:
$("#select-brand").select2({
placeholder: "Select report type",
allowClear: true,
});
@Suman Bogati请撤消您的编辑。附加代码很重要 – codecowboy
现在可以吗? –
@SumanBogati是的,谢谢 – codecowboy