Using updateFromJS is replacing values when it should be adding them

倾然丶 夕夏残阳落幕 提交于 2019-12-02 10:26:23

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.

you could always try using

$.extend(attachmentsModel.convAttachments,ko.mapping.fromJS(dataJS));

Although i am not quite sure if that will update all the bindings properly, you might have to reply the binding by calling

ko.applyBindings(attachmentsModel)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!