Git Product home page Git Product logo

Comments (5)

sagacity avatar sagacity commented on August 17, 2024

Hi abp,

This is by design. Basically, the model you pass to updateFromJS represents the 'current state' of your model that comes from your server. The mapping plugin then takes this current state and updates your mapped viewModel to match this state, so that your GUI also shows the current state.

In your example, therefore, it would remove the elements with keys '1' and '3' since they are not in your 'current state'. In a real-life scenario, maybe this is because some other user deleted items #1 and #3 since the last update occured.

If you want to do regular merging, that would be something you'd have to do yourself, manually.

I hope this explains why you are seeing this behavior. If not, feel free to reopen this ticket :)

from knockout.mapping.

abp avatar abp commented on August 17, 2024

Sure, answers my question right to the point. Sorry for reporting a bug on this. :)
Since my model is complex and rendering everything again would take far to much time i will code some simple merging by myself.

from knockout.mapping.

sagacity avatar sagacity commented on August 17, 2024

No, that's okay! When writing your merge code, please note there's a useful "ko.utils.compareArrays" available that allows you to do diffs of two arrays. That can be a good starting point for you, I think.

from knockout.mapping.

abp avatar abp commented on August 17, 2024

Thanks for the hint, but now i already have a dead simple remove/add based merging. Will see how it works out. :)

from knockout.mapping.

sagacity avatar sagacity commented on August 17, 2024

Excellent! Good luck :)

from knockout.mapping.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.