ember.js - Ember observer not getting most recent value -


i'm trying observe controller property in associated view, when so, old value. know async issues observers, per:

http://emberjs.com/guides/object-model/observers/

but using run.once() doesn't seem help. here's code:

mycontroller = ember.controller.extend({    testproperty: false,    otherthingwatcher: function() {      this.set('testproperty', true);     console.log(this.get('testproperty')); // outputs true when someotherthing changes.    }.observes('someotherthing');  });  myview = ember.view.extend({    checktestproperty: function() {      console.log(this.get('controller.testproperty')); // ack! false!      var = this;     ember.run.once(this, function() {        console.log(this.get('controller.testproperty')); // same thing.      });    }.observes('controller.testproperty');  }); 

what have missed?

versions: debug: ember      : 1.5.1 ember.js:3521 debug: ember data : 1.0.0-beta.8+canary.503c75c9 ember.js:3521 debug: handlebars : 1.3.0 ember.js:3521 debug: jquery     : 1.9.1  

there few problems code.

  1. you need use extend, not extend
  2. your observes can't end in ;

fixed code

myview = ember.view.extend({    checktestproperty: function() {      console.log(this.get('controller.testproperty')); // ack! false!      var = this;     ember.run.once(this, function() {        console.log(this.get('controller.testproperty')); // same thing.      });    }.observes('controller.testproperty')  }); 

http://emberjs.jsbin.com/cixoqeqi/1/edit


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -