简体   繁体   English

使用 emberJS 从子级重定向后触发父级重定向

[英]Trigger parent redirection after redirecting from child with emberJS

Assuming I have a route that contains another route:假设我有一条包含另一条路线的路线:

this.route('fields', function () {
  this.route('details', { path: '/:field_name' });
});

Parent route:父路线:

redirect(model, transition) {
  alert(transition.to.name);
},

Child route:儿童路线:

redirect(model, transition) {
  if (something) this.transitionTo('fields');
},

It should alert twice when I reach the child route (since there is a redirection to the parent route).当我到达子路由时,它应该会发出两次警报(因为有一个到父路由的重定向)。 It only alerts once (before the redirection).它只发出一次警报(在重定向之前)。

How can I re-trigger the parent redirect action?如何重新触发父重定向操作?

Using native class syntax:使用本机 class 语法:

redirect() {
  if (something) super(...arguments);
}

Using the Ember classic class syntax:使用 Ember 经典 class 语法:

redirect() {
  if (something) this._super(...arguments);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM