[英]Binding not firing observer in newer versions of Ember.js
我最近從Ember.js 0.9.8.1更新到Ember.js 1.0-pre2。 現在我發現在設置綁定時不會觸發觀察者。
這是一個說明問題的小例子:
模板:
<script type="text/x-handlebars">
{{view App.SimpleView textBinding="App.text"}}
</script>
碼:
App = Ember.Application.create();
App.text = "new";
App.SimpleView = Ember.View.extend({
text: 'old',
fired: 'no',
template: Ember.Handlebars.compile('Text: {{view.text}}. Observer fired: {{view.fired}}'),
textObserver: function() {
this.set('fired', 'yes');
}.observes('text')
});
使用Ember.js 0.9.8.1它按預期工作,打印Text:new。 觀察者被解雇:是的 ,( 小提琴 )然而在1.0-pre2中,觀察者沒有被解雇( 小提琴 )。
這個小像我的錯誤,但在報告之前,我想問一下API中的某些內容是否發生了變化。
好吧,在與Kristofor Selden討論之后,0.9.8.1中的行為是一個錯誤。 在1.0.pre-2中,在您的小提琴中,當實例化視圖時,App.text已經設置為“new”,這是觀察者未被觸發的預期行為。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.