debugging - In Durandal how can you get a handle to the active VM in debug or developer tool console? -


building app duranrdal first time , i'd able use chrome developer tools console inspect values of view models on various pages loaded.

the problem there no window.durandal or window.mainapp can see. in main.js define function:

window.myapp = app; 

but seems hack, , doesn't me handle current viewmodel. thought doing similar code in router, ugly.

is app & current vm accessable in clearner way? perhaps require.js when loads modules puts reference on dom somewhere? suppose if can handle router i'd ok.

i'm interested in getting handle vm backing modal dialog..not sure if can off router or other piece.

in chrome developer tools can put break points in viewmodels , step through code. also, durandal logs viewmodel objects have been composed console.log can see state @ bound view.

here way making use of mechanics of requirejs reference viewmodel object programmatically. type chrome console:

require(['durandal/pluggins/router','yourviewmodel'], function (router, vm) {     // here can whatever want router or vm.     vm.someproperty('changed');     router.activateroute('page2'); }); 

you can make global reference objects want change doing in console:

require(['durandal/pluggins/router','yourviewmodel'], function (router, vm) {     window.testvm = vm;     window.router = router; }); 

then can access objects so:

testvm.someproperty('changed'); router.activateroute('page2'); 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -