In my code, I have a knockoutJS observable array that was created in the typical way:
var MyGridModel = function(items) {
var self = this;
this.items = ko.observableArray(items);
...
Now, I want to update this array with new data. My goal here is to completely replace the old array with the new one, or at the very least, replace all the contents with those of the new array.
Below is my attempt to achieve this:
this.setData = function(newData)
{
var grid = ko.observableArray(newData);
self.items([]);
self.items(grid);
}
Unfortunately, when I run this code, the grid ends up being empty.
There seems to be something I'm overlooking. Can anyone provide guidance on how to successfully make this change?
I'm open to any suggestions or advice...