1
votes

I get paged data from server. I use ko.mapping plugin to map it into my view model. If I specify the view-model as the update target, it removes the previous data and adds the new one. I know that this is how it is suppose to work, but can I stop it from deleting existing data?

It would have been good if we can give a "destroy" function to the mapping object to give control before deleting it.

1

1 Answers

0
votes

You can make a little workaround here.

  1. Define a View-Model for the data you get from the server. so you can specify what you want to observable and what not to be.
  2. When you get your data from the server instead of using the mapping plugin to create the whole View-Model for you, you can use ko.util and loop through your data and instead of creating you data again from start, push them to your model(i guess you have arrays).

if i'm not clear, post some of your code so i can understand your case more