4
我試着觀察簡單的Ember.Select的選擇變化,它的工作原理,但是當我使用select = multiple = true時失敗。這裏是一些代碼:Ember.js如何使用視圖觀察選擇更改Ember.Select multiple = true?
{{view Ember.Select
multiple=true
contentBinding="App.TopicController"
selectionBinding="content.TOPICS"
optionLabelPath="content.label"
optionValuePath="content.id"}}
當我在我的輸入選擇變化必須引起觀察者:
App.Configuration = Em.Object.extend({
TOPICS:[],
// this observer must work when selection changes
topicsSelected: function() {
console.log('topics selection changed!');
}.observes('TOPICS', '[email protected]', 'TOPICS.length')
});
JSBin這個問題:http://jsbin.com/
版本:車把1.0.0,餘燼1.0.0
'觀察( 'topics.length')'是不夠的。如果選擇了一個項目並且用戶選擇了另一個項目,那麼長度不會改變。只是'觀察('主題。@每個')'工作正常。 –