为什么onBeforeAction触发而动作不是?

时间:2015-01-08 14:16:04

标签: meteor iron-router

在我上次流星聚会期间,我展示了IronRouter。我创建了一个项目https://github.com/MeteorLyon/tutorial-ironrouter,展示了如何管理页面和钩子。 当我使用订阅钩子时,没关系,onBeforeAction和onAfterAction在它应该在action方法之前和之后被调用。 但是当我使用waiton hook时,onBeforeAction仅在订阅准备就绪时调用(这似乎正常)但是onAfterAction被调用为data / onRun / onRerun挂钩。我希望只有在运行action方法时才会调用onAfterAction。

Router.route('/waiton', {
 waitOn: function() {
     console.info('%c waitOn - citations: %s, characters: %s', 'background: #222; color: #bada55', Citations.find().count(), Characters.find().count());
     return Meteor.subscribe('router-citations-for-waiton', Session.get('clickCount'), function() {console.warn('%c data loaded %s %s', 'background: #222; color: #bada55', Citations.find().count(), Characters.find().count());});
 },
onRun: function () {
    console.info('%c onRun - citations: %s, characters: %s', 'background: #222; color: #bada55', Citations.find().count(), Characters.find().count());
    this.next();
},
onRerun: function () {
    console.info('%c onRerun - citations: %s, characters: %s', 'background: #222; color: #bada55', Citations.find().count(), Characters.find().count());
      this.next();
},
onBeforeAction: function () {
    console.info('%c onBeforeAction - citations: %s, characters: %s', 'background: #222; color: #bada55', Citations.find().count(), Characters.find().count());
    this.next();
},
onAfterAction: function () {
    console.info('%c onAfterAction - citations: %s, characters: %s', 'background: #222; color: #bada55', Citations.find().count(), Characters.find().count());
},
onStop: function () {
    console.info('%c onStop - citations: %s, characters: %s', 'background: #222; color: #bada55', Citations.find().count(), Characters.find().count());
},
data: function() {
    console.info('%c data - citations: %s, characters: %s', 'background: #222; color: #bada55', Citations.find().count(), Characters.find().count());
    return Characters.find();
},
action: function() {
    console.info('%c action - citations: %s, characters: %s', 'background: #222; color: #bada55', Citations.find().count(), Characters.find().count());
    this.render('waiton');
    this.render('marvel_footer', {to: 'footer'});
}
});

当你转到这个网址(http://tuto-router.meteor.com/waiton)时,你会看到这种行为。

我做错了什么?

0 个答案:

没有答案