knockout.js - Can the Knockout Concurrency plugin track newly added or deleted rows? -
i'm trying use knockout concurrency plugin in project, , i'm fiddling example code, i'm not getting work:
https://github.com/andersmalmgren/knockout.concurrency/wiki/getting-started
viewmodel = function() { this.name = ko.observable("john").extend({ concurrency: true}); this.children = [{ name: ko.observable("jane").extend({concurrency: true })}, { name: ko.observable("bruce").extend({concurrency: true })}]; this.getdata = function() { //simulate backend data var data = { name: "john doe", children: [{ name: "jane doe"},{ name: "bruce wayne"}, { name: "new row"}]}; new ko.concurrency.runner().run(this, data); } } ko.applybindings(new viewmodel()); nothing happens , newly added item not tracked plugin, know why?
thanks trying out plugin, fast too, uploaded code today!
the plugin indeed support tracking of deleted , added rows. know rows needs supply mapper
var mappings = { children: { key: function(item) { return ko.utils.unwrapobservable(item.id); }, create: function(data) { return { id: data.id, name: data.name }; } } }; the name children corresponds name of array.
the key method used identify property used identifier.
the create method used create new rows (added rows).
you can download mvc3 sample github featured demo, please try out fiddle
Comments
Post a Comment