问问题
918 次
1 回答
0
我意识到你不需要听值转换器,因为selectBox
它已经在积极更新 dom 元素和插件本身。观察者中的一个简单跟踪valueChanged
可以告诉你很多事情。
根据您的问题,我提出了这个小片段。事实上,我认为它实际上就像你原来的方法。
Ember.Select.reopen({
didInsertElement: function(){
this.set('value', null);
this.$().selectBox(); // Create the jQuery plugin
},
contentChanged: function() {
//Ember.run.next is equivalent to setTimeout(fn,1);
//We want to wait for contentChanged first to finish
//then rerender selectBox.
//To get the structure of key-value is too tedious so
//just rerender it instead.
Ember.run.next(this, function() {
this.$().selectBox('refresh');
});
//Reset the selection value if you insist
//this.set('value', null);
}.observes('content')
});
我认为这样做是可以setTimeout
的,因为您需要等待首先呈现内容。刷新不应该太重。
于 2013-02-16T16:19:11.513 回答