【发布时间】:2017-04-12 07:07:37
【问题描述】:
我将如何更新 select2 下拉菜单的值?
我已经看过这里,但我测试的任何内容都没有更新下拉列表中的替换数据。 - Update select2 data without rebuilding the control
【问题讨论】:
我将如何更新 select2 下拉菜单的值?
我已经看过这里,但我测试的任何内容都没有更新下拉列表中的替换数据。 - Update select2 data without rebuilding the control
【问题讨论】:
抱歉,写得不及格,我是在累的时候写的。但是我注意到这个主题没有任何问题/答案,我最终得到了它。
我觉得自己有点像一个混蛋,因为没有早点弄清楚这一点。
$('#element').select2().empty(); // empty the select2
$('#element').select2({ placeholder: 'Select A Model', data: data }); // fill the existing select2 with the data
【讨论】: