Donnerstag, 27. Februar 2014

knockout.js MVVM: ko.mapping.fromJS - advanced mapping technique not found in template's code

According to the knockout.js tutorial there is an advanced mapping technique available via plugin (knockout.mapping.js) to automatically map JSON based data that is retrieved/sent by AJAX calls to/from knockout viewmodel.

Tutorial: http://knockoutjs.com/documentation/plugins-mapping.html
Download: https://github.com/SteveSanderson/knockout.mapping/tree/master/build/output

This key word was not found yet within the template's code base. Therefore it is not used for now. The mapping is done "manually".

Code snippet from knockout.js tutorial.
var viewModel = ko.mapping.fromJS(data);

The creation of a viewmodel object is done explicitily in template:
var app = new AppViewModel(new AppDataModel());

Keine Kommentare:

Kommentar veröffentlichen