javascript - kendo requirejs access viewmodel from another module -
how 'get' , 'set' properties of 1 viewmode's requirejs module?
test.js ================ define(['kendo'], function (kendo) { var vm = kendo.observable({ propertya: "a" }); return {vm: vm}; }); another.js ================ define(['kendo'], function (kendo) { var testmethod = function () { var test = require(['test']); var testname = test.vm.get("propertya"); //<< uncaught typeerror ??? test.vm.set("propertya", "b"); //<< uncaught typeerror ??? }; return {testmethod: testmethod}; }); i'm sorry because have c# background , not used work js unless current project.
should add methods test.js vm , set properties of viewmodel or there way can , set properties (propertya example) directly module?
you can't way doing it. call require asynchronous. test won't have value want.
you this:
define(['kendo', 'test'], function (kendo, test) { var testmethod = function () { var testname = test.vm.get("propertya"); //<< uncaught typeerror ??? test.vm.set("propertya", "b"); //<< uncaught typeerror ??? }; return {testmethod: testmethod}; });
Comments
Post a Comment