Question

I have a Durandaljs application. I want to have a back button in shell view that should be hidden depends on which view is activated now. What is the easiest way to detect navigation event in shell viewmodel to change back button visibility state?

Was it helpful?

Solution

Basic Solution

You can check what view is activated using router via router.navigationModel()[x].isActive

Application Messaging

You can in the Activation event of ViewModel use Durandal Application-Wide Messaging

In view model in Activate function include

app.trigger('viewNavigated', isBackVisable);

While in shell view model

app.on('viewNavigated').then(function(isBackVisable)
{
     if(isBackVisable)
          MakeButtonBackVisable();
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top