我是 knockout.js 的新手,想开始使用自动映射插件。如何将此手动映射的代码转换为使用映射插件?
http://jsfiddle.net/infatti/jWTtb/6/
// Here's my data model
var ViewModel = function (firstName, lastName) {
var self = this;
self.firstName = ko.observable(firstName);
self.lastName = ko.observable(lastName);
self.loadJson = function () {
$.getJSON("http://echo.jsontest.com/firstName/Stuart/lastName/Little",
function (data) {
self.firstName(data.firstName);
self.lastName(data.lastName);
});
return true;
};
};
var vm = new ViewModel();
ko.applyBindings(vm); // This makes Knockout get to work