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

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -