我试图让dynatree控制在Hottowel视图模型的工作,在此基础上拨弄, http://jsfiddle.net/EZgNs
var ViewModel = function() {
var self = this;
self.initialized = ko.observable(false);
self.items = ko.observableArray();
// Use JSFiddle echo to simulate an AJAX service
(function() {
$.ajax({ url:"/echo/json/", data:data, type:"POST",
success:function(data)
{
// Map the returned JSON to the View Model
ko.mapping.fromJS(data, {}, self.items);
self.initialized(true);
}
});
})();
};
ko.bindingHandlers.dynatree = {
update: function(element, valueAccessor, allBindingsAccessor, viewModel) {
setTimeout( function() { $(element).dynatree()}, 0);
}
};
ko.applyBindings(new ViewModel());
唔明如何编辑虚拟机纳入dynatree KO。