Reputation: 7448
My view displays a list composed objects all stored in koObservableArray MM.slideWellThumbnails
The objects are displayed using data-bind="foreach: slideWellThumbnails"
I couldn't get an individual view of an object updated, when only one property (e.g. confirmed
) of an object was changed.
MM.slideWellThumbnails.valueHasMutated();
MM.slideWellThumbnails.extend({notify:
'always'});
It didn't help.
What I'm currently doing is, making a copy of the array, clearing the entire array and then pushing the data back to the array. It works, but I guess it is not as the KO-inventor ment it.
MM.slideWellThumbnails()[ +well ].confirmed = confirmed;
MM.slideWellThumbnails1([]);
ko.utils.arrayForEach( MM.slideWellThumbnails(), function(data)
{
MM.slideWellThumbnails1.push( data );
});
MM.slideWellThumbnails([]);
ko.utils.arrayForEach( MM.slideWellThumbnails1(), function(data)
{
MM.slideWellThumbnails.push( data );
});
Is there an efficient way to do it?
Upvotes: 0
Views: 388
Reputation: 7448
Thanks to James Thorpe I could fix it:
Declared confirmed as observable:
var MyDataStructure= function( /*args*/ ) {
//...
this.confirmed = ko.observable(false)
//...
}
and assigned new value with:
//+well for explicitly converting to int from string
MM.slideWellThumbnails()[ +well ].confirmed(confirmed);
Thanks!
Upvotes: 1