ember.js - ComputedProperty on a component only updates the first time the watched property is set to a given value (when the property is a model property) -


i seem having bit of issue computed properties on ember 1.7.0 inside of component. let's have 2 models, & b. has "belongsto" relationships b.

on component template have ember.select control allow 1 select b entry a.

{{view ember.select class="form-control" content=blist selection=objecta.objectb optionvaluepath="content.id" optionlabelpath="content.name"}} 

in component have computed property watches changes on objecta.objectb so:

issomething: function() {     return this.get("objecta.objectb.id") === "some id"; }.property("objecta.objectb"), 

then in component template conditionally display based on value of issomething:

{{#if issomething}}     :d {{/if}} 

if place breakpoint in issomething computed property, , select new value on select control, hits breakpoint expected. hit again after select new value. if select original value again, breakpoint not hit (and component not rerender). seems hitting first time select given value in select control. @ first thought may issue caching, adding volatile() property didn't seem make difference.

i can around binding select control selection property on component tempobjectb, , changing property being monitored issomething tempobjectb follows:

issomething: function() {     return this.get("tempobjectb") === "some id"; }.property("tempobjectb"), 

then keep objecta's reference updated can use method observes changes tempobjectb , updates objecta.objectb follows:

updateobjecta: function() {     this.set("objecta.objectb", this.get("tempobjectb")); }.observes("tempobjectb"), 

these changes allow breakpoint hit every single time change value in select control.

does know causing behaviour? i'd rather not resort creating temporary variable.

  1. http://jsbin.com/qeyite/1/edit?html,js,output

  2. http://jsbin.com/kugino/3/edit?html,js,output

the difference between 2 first bin storing , watching on objecta.objectb, while second bin storing , watching on tempobjectb.

for stumbles accross this, appears fixed of latest ember.js release (1.8.1).

https://github.com/emberjs/ember.js/issues/5578


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -