发布于 2014-12-01 08:48:58
它在当前生产的Ember.js版本(1.8)和把手版本(1.3)中工作,只需调用视图中的selectpicker()的didInsertElement函数即可。
didInsertElement: function(){
$("#selectPicker").selectpicker()
}例如,请参见JSFiddle。
在早期版本的Ember中,由于呈现工具栏模板的方式,它可能无法工作。
发布于 2013-05-15 15:06:38
这不是引导选择组件,而是select2 (好得多:),这就是我们如何设置它来很好地处理成员选择视图:
App.Select2SelectView = Ember.Select.extend({
prompt: 'Please select...',
classNames: ['input-xlarge'],
didInsertElement: function() {
Ember.run.scheduleOnce('afterRender', this, 'processChildElements');
},
processChildElements: function() {
this.$().select2({
// do here any configuration of the
// select2 component
});
},
willDestroyElement: function () {
this.$().select2("destroy");
}
})然后我们就像这样使用它:
<div class="controls">
{{view App.Select2SelectView
id="mySelect"
contentBinding="App.staticData"
optionValuePath="content.id"
optionLabelPath="content.label"
selectionBinding="controller.selectedId"}}
</div>我认为,尽管对于select2组件,您可以使用相同的钩子、didInsertElement和willDestroyElement来引导select。
如果您真的需要引导选择,那么这可能是您需要的东西:https://github.com/emberjs-addons/ember-bootstrap
希望它能帮上忙
发布于 2013-10-12 03:30:05
我还添加了这些内容,以使select2选择能够对selectionBinding的更改做出反应:
_underlyingSelectionDidChange: Ember.observer((function() {
this.$().select2('val', this.$().val().toString());
}), "selection.@each");https://stackoverflow.com/questions/16566700
复制相似问题