Ember.js Alertify不使用来自路线的余烬过渡

Ember.js Alertify不使用来自路线的余烬过渡,ember.js,ember-cli,alertify,alertifyjs,Ember.js,Ember Cli,Alertify,Alertifyjs,当有人试图从页面导航时,我尝试使用alertify确认框。但是在路由的willTransition操作中,alertify是非常异步的,并且ember不等待确认。无论单击什么,页面都已导航 willTransition(transition) { alertify.confirm('Confirm', 'Are you sure you want to navigate?', function(e) { if(e) { return true; } else {

当有人试图从页面导航时,我尝试使用alertify确认框。但是在路由的willTransition操作中,alertify是非常异步的,并且ember不等待确认。无论单击什么,页面都已导航

willTransition(transition) {
  alertify.confirm('Confirm', 'Are you sure you want to navigate?', function(e) {
    if(e) {
     return true;
    } else {
     transition.abort();
    }
  });
}

请帮我做这个

您可以中止并重试转换。在显示确认对话框之前,必须中止转换。确认对话框后,可以重试转换,并防止代码再次显示确认对话框。因此,以下各项应有效(未经测试):

export default Ember.Route.extend({

  // ...

  showConfirmation: true,

  actions: {
    willTransition(transition) {
      if(!this.get('showConfirmation')) {
        this.set('showConfirmation', true);
        return true;
      }
      // Abort the transition for now
      transition.abort();

      // Now show a confirm box with alertify.
      // According to the docs, only the following 
      // is allowed: http://alertifyjs.com/confirm.html

      alertify.confirm('Are you sure you want to navigate?', () => {   
        // According to the documentation of alertify, 
        // this code is only run when you confirm your box.
        this.set('showConfirmation', false);
        transition.retry();
      });
    }
  }
}