簡體   English   中英

Ember.js如何通過視圖Ember觀察選擇變化。選擇倍數=真?

[英]Ember.js How to observe selection changes with view Ember.Select multiple=true?

我試圖觀察簡單Ember.Select的選擇更改並且它可以工作,但是當我使用select with 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', 'TOPICS.@each', 'TOPICS.length')

});

JSBin有這個問題: http//jsbin.com/

版本 :車把1.0.0,ember 1.0.0

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

在您的topicsSelected觀察者中,如果您想觀察選擇,則需要observes('topics.length')

看看你更新的jsbin http://jsbin.com/ofONeQ/14/edit

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM