从组件刷新/重新加载余烬路线 [英] Refresh / Reload ember route from a component

查看:79
本文介绍了从组件刷新/重新加载余烬路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个组件,它实际上是一个模式对话框。
完成该对话框后,按确定按钮,我想停留在打开该对话框的停留页面上。
并不困难。

I have a component, that's actually a modal dialog. When I am done with that dialog and press the "Ok" button, I want to stay on the stay page from where I opened that dialog. Which isn't difficult.

但是问题是对话框更改了数据(我正在通过REST调用获取数据),所以我需要刷新

But the problem is that the dialog changes the data (I am getting data through a REST call) so I need to refresh the route that I already am on to reflect the data changes.

因为我是从组件中调用它的,所以没有 Route 所以不能调用 route.refresh()

Since, I am calling it from a component, I don't have Route so can't call route.refresh().

我试图获取路由器:

this.set('router',Ember.getOwner(this).lookup('router:main'));

并转换到同一页面:

_this.get('router')。transitionTo('my-route')

但是由于路线没有改变(我只打开对话框),不会触发 transitionTo

But since the route hasn't changed (I only opened a dialog), transitionTo doesn't get triggered!

有没有一种方法可以强制触发 transitionTo 还是刷新我所在的页面?

Is there a way I can force trigger transitionTo or refresh the page that I am on?

谢谢!

推荐答案

为此,请在中定义 refreshCurrentRoute 方法

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

在组件中,您需要调用 refreshCurrentRoute 操作。您可以使用 ember-route-action-helper 或通过传递闭包动作。

From your component, you need to call refreshCurrentRoute action. either you can use ember-route-action-helper or by passing the closure action.

这篇关于从组件刷新/重新加载余烬路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆