【发布时间】:2023-03-23 13:09:01
【问题描述】:
这是我模板中的一个 sn-p (Backbone with Marionette):
<div class="form-group">
<label for="some_id" class="align-left col-sm-4 control-label">Some Label</label>
<div class="col-sm-7">
<select id="some_id" style="width:150px;" data-minimumresultsforsearch="10" />
</div>
</div>
然后在使用模板的 View 的 onShow 方法中:
types = ['Type 1', 'Type 2'];
this.$("#some_id").select2({
data: types
});
这是 select2 v4.0。类型出现,但 minimumresultsforsearch 没有任何效果。不知道怎么调试,欢迎提出建议!
仅供参考,我试图在 html 中进行一些配置的原因是,据我所知,我必须在 onShow 中使用相同的配置选项,然后在需要该元素的任何方法中再次使用更新了,所以我重复了很多代码。如果我可以将它们放在 html 中,我想我只需要在 javascript 中使用相关选项,即“数据:”。
【问题讨论】:
标签: javascript jquery backbone.js jquery-select2 html5-data