0
如果在我的模板中選擇此選項,會使我的模型變髒並觸發init上的觀察者,爲什麼?我想能夠在更改時更新模型,但是現在我的更新函數在init中觸發,我不想在init上的每個項目上都進行api調用。Ember在初始化時選擇使模型變髒
模板:
{{#each booking in bookings itemController="booking"}}
{{isDirty}} // this is true
{{view "select" content=dateRange value=booking.playingOn optionValuePath="content.date" optionLabelPath="content.day"}}
{{/each}}
控制器:
// this is running on init and when you select something in the select drop down.
updatePlayingOn: function(){
console.log(this.get('currentState.stateName')); // logs root.loaded.updated.uncommitted
}.observes('playingOn')
正如我理解值= booking.playingOn更新playingOn模型屬性爲相同的值,使該模型髒。
謝謝你的提示!有一個選擇支持模型使用DS.attr('數字')的問題,改爲字符串解決了我。 – 2015-03-25 13:46:25