我无法使用一些延迟加载Technic来重置具有新值的可观察数组.我可以清除但无法重置,但它不允许我添加新的动态值.
小提琴 http://jsfiddle.net/kspxa8as/
JS
var i = 1;
optionsProvider = function(self) {
var self = self || {};
self.options = {};
self.get = function(name, initialValue) {
if (!self.options[name]) {
console.log("Called - " + name);
self.options[name] = ko.observableArray([initialValue]);
var requestHeader = '';
setTimeout(function() {
var aa = [{name: "plant 1" + i, selected: true}, {name: "palnt 2" + i, selected: false}];
self.options[name](aa);
i++;
}, 2000);
}
return self.options[name];
};
return self;
};
ViewModel = function() {
var self = this;
var …Run Code Online (Sandbox Code Playgroud)