knockout.js - How to use knockout mapping plugin with Durandal? -


i'm new in durandal, , wanted rewrite existing knockout project using framework. in old project i'm using knockout mapping plugin , have problem it. work durandal sample project base. here piece of code:

define(['durandal/app', 'durandal/system', 'knockout'], function (app, system, ko) {      var clients = ko.observablearray([]);      return {             clients: clients,          activate: function(data) {             var self = this;             ko.mapping.fromjs(getdata(), {}, self.clients);         }     }; }; 

the error is:

uncaught typeerror: cannot call method 'fromjs' of undefined

indeed, undefined, should add , make working?

thanks.

you should add mapping plugin in defineotherwise not going load it.

define(['durandal/app', 'durandal/system', 'knockout', 'knockout-mapping'], function (app, system, ko) { 

make sure able load script in requirejs configuration.

i suggest load knockout , mapping plugin in main.jsso don't need keep "requiring" them in viewmodels. can bundle them separately , not part of loader.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -