Search code examples
javascriptjquerydurandalsingle-page-applicationdurandal-2.0

Durandal viewChanged event in shell.js


How I can listen view change event in shell.js ?

I want to generate href for a tag when new view activates

Im using Durandal 2.x


Solution

  • You could try subscribing to the activeInstruction observable of the router in shell.js

    define(['plugins/router', 'durandal/app'], function (router, app) {
    
        router.activeInstruction.subscribe(function (configObject) {
            console.log('activeInstruction', configObject);
        });
    

    . . .

    this will give you a config object which will contain info on where you are navigating too. Not sure if this is the best method or not or even if it's designed to be used this way but have a look, it might help.