Ember:willTransition()在路由中断链接到辅助活动类

时间:2017-08-13 04:22:18

标签: javascript ember.js handlebarshelper

将此操作添加到我的路线后:

  actions: {
    willTransition() {
      this.refresh();
    }
  }

模板中引用嵌套路线的所有链接都标记为有效,即使它们生成的网址不同的动态网段

我做了一个Ember Twiddle to reproduce the bug。它只发生在willTransition()动作,而不是redirect()钩子。 (我需要使用willTransition刷新父路由。)

有一点需要提及:首先渲染所有内容都是有序的。当willTransition被触发时它会中断。

有什么想法吗? :)

更新

似乎导致问题的是this.refresh()而不是willTransition()操作。

1 个答案:

答案 0 :(得分:0)

我不确定这是不是因为你快速制作小提琴......但你作为参数传递的模型不应该在引号中

{{link-to 'route.destination' 'Visual representation' model.thing}}

内联vs块//内联总是令人困惑...如果文本的'值'是定义差异......它应该是第一个参数...

{{#link-to 'route.destination' model.thing}}
  <span>{{model.name}}</span>
{{/link-to}}

https://ember-twiddle.com/702ab44ba8090a50cfabda353cffc599

这个稍微复杂的小提琴表明它运作正常......我想......让我知道。 :)

编辑:我看到你正在对细分做什么......并利用默认值 - 但也有这个错误:/paternt' did not match any routes in your application

我开始认为这种行为是正常的。它们都处于活动状态,因为您处于默认的parent.sibling.index

我建议您将事情设置为这样,然后查看问题是否仍然存在

Router.map(function() {
  this.route('parent', function(){
    this.route('child-list' {path: '/'});
    this.route('child-detail', {path: ':thing'});
  })
});

(我一直试图分叉你的旋律 - 但它只是重定向到我的小提琴......笨拙的东西)