Manuel Ceron
Manuel Ceron

Reputation: 8456

Binding not firing observer in newer versions of Ember.js

I recently updated from Ember.js 0.9.8.1 to Ember.js 1.0-pre2. Now I find that observers are not fired when I set bindings.

Here is a small example illustrating the problem:

Template:

<script type="text/x-handlebars">
    {{view App.SimpleView textBinding="App.text"}}
</script>​

Code:

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')
});

With Ember.js 0.9.8.1 it works as expected, printing Text: new. Observer fired: yes​, (fiddle) however in 1.0-pre2, the observer is not fired (fiddle).

This small like a bug to me, but before reporting it, I would like to ask if something in the API changed.

Upvotes: 0

Views: 280

Answers (1)

sly7_7
sly7_7

Reputation: 12011

Well, after discussion with Kristofor Selden, the behavior in 0.9.8.1 was a bug. In 1.0.pre-2, in your fiddle, when the view is instantiated, App.text is already set to "new", this is an expected behavior that the observer is not fired.

Upvotes: 2

Related Questions