【发布时间】:2016-11-27 00:39:22
【问题描述】:
我正在使用 select2 v4.0.3 和 JQuery。 我将我的选择器初始化为:
$("#datatype").select2({
theme: "classic"
});
$("#unit").select2({
theme: "classic"
});
然后我想检测#datatype 的变化并更改#unit 的值,我这样做如下:
$("#datatype").on('select2:select',function () {
$("#unit").val('21'); //udpate unit type to be 'none'
});
问题是#unit 的值被设置为 21,但该选择器的显示标签没有更新。有什么建议吗?
似乎 select2 不知道该事件,或者它没有正确设置以侦听更改。我不确定解决方案是什么。我是网络技术的新手。
【问题讨论】:
标签: jquery-select2 select2 jquery-select2-4