knockout.js - How to dynamic render data after ajax with knockout.mapping.js? -
i'm using knockout.js & knockout.mapping.js. alter info resource ajax, info couldn't refresh dynamically.
because in actual project, wanner customize html modules without alter js code, , info not certain, info construction complex , dynamic. 2 main goals want achieve:
1, multi-levels data, utilize knockout.mapping, it's not working. here example: http://jsfiddle.net/8ukal/
2, dynamic source, resources may have data2, data3, ...
, , can alter source ref data2
data3
easily, thought should utilize <div data-bind="foreach: resources_ajax(key)" data-key="data1">
in html.
is there solution?
thanks.
you need think differently. knockout data-binding model dom, update dom on behalf. trying "call model" dom
updated code show example, key part:
.done(function(data) { data.data1 = json.parse(data.data1); // line prepare false ajax request self.resources_ajax(data.data1); });
jsfiddle:
http://jsfiddle.net/m389e/
knockout.js knockout-mapping-plugin
No comments:
Post a Comment