Using updateFromJS is replacing values when it should be adding them

前端 未结 2 1217
我在风中等你
我在风中等你 2021-01-26 04:42

I have this code:

var attachmentsModel = {
    convAttachments: ko.mapping.fromJS([])
};

$(function() {
    ko.applyBindings(attachmentsModel)
    refreshConvAt         


        
2条回答
  •  [愿得一人]
    2021-01-26 05:14

    ko.mapping.updateFromJS() expects that you are receiving the complete list of items that was originally prepared with ko.mapping.fromJS(). Any items that are missing from the original are considered to be deleted and any new items in the updates are considered additions. So, currently the mapping plugin will not allow you to do incremental updates in this way.

    If you are doing incremental updates, your best bet would be to locate the items that you need to update and either replace them completely or replace individual observables on each item.

提交回复
热议问题