最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to reload page in Ember or Jquery - Stack Overflow

programmeradmin0浏览0评论

How can i force a reload instead of a transition in Ember.Route

For example inside this function:

File: play_route.js

actions: {
    willTransition: function(transition, route) {
        transition.abort();
        transition.refresh();
        // maybe
        // window.location.href = route;
    }
}

How can i force a reload inside Ember.Controller

For example inside this function:

File: play_controller.js

actions: {
    reloadPage: function() {
        // reload baby
    }
}

How can i force a reload instead of a transition in Ember.Route

For example inside this function:

File: play_route.js

actions: {
    willTransition: function(transition, route) {
        transition.abort();
        transition.refresh();
        // maybe
        // window.location.href = route;
    }
}

How can i force a reload inside Ember.Controller

For example inside this function:

File: play_controller.js

actions: {
    reloadPage: function() {
        // reload baby
    }
}
Share Improve this question asked Aug 6, 2014 at 14:56 eguneyseguneys 6,3967 gold badges34 silver badges81 bronze badges 6
  • 1 Why not use window.location.reload()? – Casey Falk Commented Aug 6, 2014 at 14:59
  • What is the compatibility with Ember? – eguneys Commented Aug 6, 2014 at 14:59
  • It is pure JavaScript. Does ember disable pure JavaScript? – Casey Falk Commented Aug 6, 2014 at 15:00
  • What about my second question, which is reloading to a specific Ember.Route instead of a transition? – eguneys Commented Aug 6, 2014 at 15:01
  • Why are you needing to reload the page? – Kingpin2k Commented Aug 6, 2014 at 20:15
 |  Show 1 more comment

2 Answers 2

Reset to default 15

This should do the trick:

window.location.reload(true);

So according to you guys I've solved my both problems as follows, acknowledge if this is the proper way to do this.

In controller i refresh the page:

window.location.reload(true);

In route i transition to specific route:

actions: {
    willTransition: function(transition, route) {
        transition.abort();

        window.location.href = '/' + transition.targetName;
    }
}
发布评论

评论列表(0)

  1. 暂无评论