var MyImage = function (_id, _url) {
this.url = ko.observable(_url);
//...other properties
}
In my viewmodel I have an observableArray like this (note: I have removed the unnecessary stuff:
var self = this;
self.myImages = ko.observableArray([
]):
....within an event function, I make a GET call using AJAX that returns some JSON with the new URL
//parse the JSON
var newAttr = jQuery.parseJSON(obj.Message);
var currImg;
self.myImages.valueWillMutate();
self.myImages().forEach(function (item) {
item.url = newAttr.url;
currImg = item;
}
});
self.myImages.valueHasMutated();
I tried this, and it's still not working. I have to do this to get it to refresh:
self.myImages.remove(currImg);
self.myImages.push(currImg);
This works, but then my images are no longer in order and the image is appended to the end. It's a work around, but I am guessing I have something setup wrong and knockout should handle the change.