Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reload page in Ember or Jquery

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
    }
}
like image 203
eguneys Avatar asked Aug 06 '14 14:08

eguneys


People also ask

How do I refresh a model in Ember?

To refresh your ember model you can use this. refresh(); . Actions should be on controller not on route accordingly to last RFC discussion about route-action helper. I would recommend to move the refreshModel() action to controller.

How do I reload a page in JavaScript?

You can use the location. reload() JavaScript method to reload the current URL. This method functions similarly to the browser's Refresh button. The reload() method is the main method responsible for page reloading.

What is location reload in jquery?

The location. reload() method reloads the current URL, like the Refresh button.

What is reload in JavaScript?

Definition and Usage. The reload() method reloads the current document. The reload() method does the same as the reload button in your browser.


2 Answers

This should do the trick:

window.location.reload(true);
like image 50
Mike Cluck Avatar answered Oct 19 '22 22:10

Mike Cluck


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;
    }
}
like image 22
eguneys Avatar answered Oct 19 '22 23:10

eguneys