knockout.js - Computed observable does not update -


i have computed observable looks this:

this.isactive = ko.computed<boolean>(function () {     this.structure().valuesets();     return this.structure().containsvalueset(this.valueset()); }, this); 

this.structure() instance of structurevm class (i'm using typescript). containsvalueset function inside structurevm class looks this:

containsvalueset(valuesetvm:valuesetvm):boolean {     var valueset:valuesetvm = _.find(this.valuesets(), function (valueset:valuesetvm) {         if (valueset.id === valuesetvm.id) {             return true;         }     });     return (objects.isinstantiated(valueset)); } 

i'm using _.find on list of valuesetvm (this.valuesets()).the computed not updated when added valuesets array. why that? i'm assuming there wrong dependency chain?

is due usage of underscore?

kind regards,

denewout.

i needed make sure use .push on observable array instead on native javascript array. give example, should have used this:

structure().valuesets.push(valueset); 

instead of:

structure().valuesets().push(valueset); 

thanks james thorpe reminding me.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -