如何在Durandal中手动触发视图模型的激活?

时间:2014-09-21 10:25:23

标签: knockout.js durandal

Durandal docs使用激活剂很少。我正在尝试从nav viewmodel手动触发home视图模型的激活。我该怎么做?

shell.html

<section>
  <!-- ko compose: {model: nav} --><!-- /ko -->

  <section data-bind="router: {cacheViews: true}"></section>
</section>

home.js

define(function (require) {
   var nav = require('viewmodels/nav'),
   activate = function() {
      //how to activate nav manually here?
      //I am looking for something like:

      //return activator.activate(nav);

      //that would fire the transition of the *nav* module and would allow me to reuse
      //the transition promise and delay activation of *home* module
   };

   return {activate: activate, nav: nav};

});

nav.js

define(function (require) {
   var activate = function() {
       //is this the correct way to disable auto-activation 
       //of viewmodel during composition?
      return false;
   };

   return {activate: activate};

});

0 个答案:

没有答案