Meteor 1.0:使用 iron:router 单击按钮时显示加载屏幕

Meteor 1.0: Show loading screen on button click with iron:router

我有一个按钮。单击此按钮时,我想显示加载模板(使用 sacha:spin)5 秒。

  'click #submit-air': (e,t) ->
    e.preventDefault()
    ...

我正在使用 iron:router,根据我在文档中阅读的内容,答案似乎在 hooks 中的某处,但我无法弄清楚。在同一路线上显示加载模板一定秒数的最佳方法是什么?这可能吗?

我根本不会使用铁路由器。尝试这样的事情:

Session.setDefault('loading', false);

Template.something.helpers({
  loading: function() { return Session.get('loading');}
});
Template.something.events({
  'click button': function(e,t) {
    Session.set('loading', true);
    Meteor.setTimeout(function(){
      Session.set('loading', false);
      // anything else you want to do. Maybe Router.go('somewhere else')
    }, 5000); // wait 5 seconds
});

现在在您的模板中:

{{#if loading}}{{>spinner}}{{else}}
  <-- your template with a button--!>
{{/if}}