knockout.js - Knockout Mapping plugin in Durandal giving undefined -


i'm having problem i've trying solve 2 days , give up, last resource, i'm trying load json response observablearray (ko) in durandal everytime call function ko.mapping.fromjson comes following error:

uncaught typeerror: cannot call method 'fromjson' of undefined  

i understand need download plugin , load on main.js

requirejs.config({ paths: {     'text': '../lib/require/text',     'durandal':'../lib/durandal/js',     'plugins' : '../lib/durandal/js/plugins',     'transitions' : '../lib/durandal/js/transitions',     'knockout': '../lib/knockout/knockout',     'mapping': '../lib/knockout/knockout.mapping',     'bootstrap': '../lib/bootstrap/js/bootstrap',     'jquery': '../lib/jquery/jquery-1.9.1' }, urlargs: 'v=1.0.0.1', shim: {     'bootstrap': {         deps: ['jquery'],         exports: 'jquery'    } } }); 

knockout working fine, i'm able update fields , everything, when try use ko.mapping i'm having problems:

define(['durandal/app', 'plugins/router', 'knockout', 'mapping'], function (app, router, ko) {  var clients = ko.observablearray([]);  return {     displayname: 'my page',     clients: clients,     activate: function () {          return $.ajax({             type: "post",             url: "backend/serverservices.php",             data: {                 s: 'listadodeclientes'             }         }).then(function( msg ) {             ko.mapping.fromjson(msg, clients);          });      },     showmessage: function () {         router.navigate('crearcliente');     } }; }); 

in order use ko.mapping plugin require.js have manualy set ko.mapping variable ko.mapping library or use injected variable instead.

sample:

define(['durandal/app', 'plugins/router', 'knockout', 'mapping'], function (app, router, ko, mapping) {    ko.mapping = mapping;    ko.mapping.fromjson(...     //or use injected mapping parameter    mapping.fromjson(...   } 

look @ answer on this question.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -