我想得到引导选择 https://github.com/silviomoreto/bootstrap-select使用 Ember.js。 Ember 对视图对象的管理存在一些问题,导致其无法按预期工作。
JSFiddle http://jsfiddle.net/TheWorkerAnt/8d2Me/1/
$("select").selectpicker()
对于正常选择工作正常,并替换 Ember.Select 视图 HTML,但 Ember 的视图已损坏。
The .ember-view
类是这里的负责人,您可以破解它以从选择和选项中删除该类,以使引导选择工作,但当然 ember 不再关注它,从而达到了目的。
有人足够了解 EmberView 来完成这项工作吗?我应该尝试覆盖 Ember.Select 吗?或者 bootstrap-select 是否需要更改?我在源代码的海洋中漂流。
这不是引导选择组件,而是select2 http://ivaynberg.github.io/select2/(好多了:)这就是我们如何设置它以与 ember 选择视图很好地配合:
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 http://ivaynberg.github.io/select2/您可以使用相同的钩子组件didInsertElement
and willDestroyElement
对于引导选择组件。
如果您确实需要引导选择,那么也许这适合您:https://github.com/emberjs-addons/ember-bootstrap https://github.com/emberjs-addons/ember-bootstrap
希望能帮助到你
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)