2013-10-24 113 views
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

回答

4

TOPICS變量變更爲topics將解決這一問題。我認爲這是因爲這個問題https://github.com/emberjs/ember.js/issues/3098

在你topicsSelected觀察者,如果你想觀察只是需要observes('topics.length')選擇。

給您更新jsbin看看http://jsbin.com/ofONeQ/14/edit

+0

'觀察( 'topics.length')'是不夠的。如果選擇了一個項目並且用戶選擇了另一個項目,那麼長度不會改變。只是'觀察('主題。@每個')'工作正常。 –