DurandalJS导航活动

时间:2014-01-18 12:15:26

标签: durandal durandal-navigation

我有一个Durandaljs应用程序。我希望在shell视图中有一个应该隐藏的后退按钮取决于现在激活哪个视图。在shell视图模型中检测导航事件以更改后退按钮可见性状态的最简单方法是什么?

1 个答案:

答案 0 :(得分:1)

基本解决方案

您可以通过router.navigationModel()[x].isActive

检查使用路由器激活的视图

应用程序消息

您可以在ViewModel的Activation事件中使用Durandal Application-Wide Messaging

在视图模型中激活功能包括

app.trigger('viewNavigated', isBackVisable);

在shell视图模型中

app.on('viewNavigated').then(function(isBackVisable)
{
     if(isBackVisable)
          MakeButtonBackVisable();
});
相关问题