Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

API Allow to force URL reload, while replacing the history state

Comes with a wrapper for easy reloading of the current panel.
  • Loading branch information...
commit 70eaa270e4326ab3c46951a0401b12ea73925757 1 parent a58cb37
Mateusz U mateusz authored chillu committed
Showing with 16 additions and 2 deletions.
  1. +16 −2 admin/javascript/LeftAndMain.js
18 admin/javascript/LeftAndMain.js
View
@@ -162,8 +162,9 @@ jQuery.noConflict();
* - {String} url
* - {String} title New window title
* - {Object} data Any additional data passed through to History.pushState()
+ * - {boolean} forceReload Forces the replacement of the current history state, even if the URL is the same, i.e. allows reloading.
*/
- loadPanel: function(url, title, data) {
+ loadPanel: function(url, title, data, forceReload) {
if(!data) data = {};
if(!title) title = "";
@@ -187,13 +188,26 @@ jQuery.noConflict();
if(window.History.enabled) {
// Active menu item is set based on X-Controller ajax header,
// which matches one class on the menu
- window.History.pushState(data, title, url);
+ if(forceReload) {
+ // Add a parameter to make sure the page gets reloaded even if the URL is the same.
+ $.extend(data, {__forceReload: Math.random()});
+ window.History.replaceState(data, title, url);
+ } else {
+ window.History.pushState(data, title, url);
+ }
} else {
window.location = $.path.makeUrlAbsolute(url, $('base').attr('href'));
}
},
/**
+ * Nice wrapper for reloading current history state.
+ */
+ reloadCurrentPanel: function() {
+ this.loadPanel(window.History.getState().url, null, null, true);
+ },
+
+ /**
* Function: submitForm
*
* Parameters:
Please sign in to comment.
Something went wrong with that request. Please try again.