Permalink
Browse files

BUG Force "full" ajax content reload with invalid fragments

When one or more fragments are requested that are not in
the current DOM, we need to force loading the outermost
fragment instead (currently hardcoded to "Content").
This mainly prevents history back navigation from breaking,
e.g. admin/pages -> admin/pages/list ->
admin/pages/list/?ParentID=99 -> admin/pages/edit/show/5 -> (back)
  • Loading branch information...
1 parent 8d3d3a7 commit a5a08530fc88ed0bc61cab9c0e794a76d24fbf63 @chillu chillu committed Jul 13, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 admin/javascript/LeftAndMain.js
@@ -287,7 +287,8 @@ jQuery.noConflict();
var self = this, h = window.History, state = h.getState(),
fragments = state.data.pjax || 'Content', headers = {},
- contentEls = this._findFragments(fragments.split(','));
+ fragmentsArr = fragments.split(','),
+ contentEls = this._findFragments(fragmentsArr);
// For legacy IE versions (IE7 and IE8), reload without ajax
// as a crude way to fix memory leaks through whole window refreshes.
@@ -297,6 +298,14 @@ jQuery.noConflict();
document.location.href = state.url;
return;
}
+
+ // If any of the requested Pjax fragments don't exist in the current view,
+ // fetch the "Content" view instead, which is the "outermost" fragment
+ // that can be reloaded without reloading the whole window.
+ if(contentEls.length < fragmentsArr.length) {
+ fragments = 'Content', fragmentsArr = ['Content'];
+ contentEls = this._findFragments(fragmentsArr);
+ }
this.trigger('beforestatechange', {state: state, element: contentEls});

0 comments on commit a5a0853

Please sign in to comment.