Skip to content

Commit

Permalink
BUG Force "full" ajax content reload with invalid fragments
Browse files Browse the repository at this point in the history
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
chillu committed Jul 13, 2012
1 parent 8d3d3a7 commit a5a0853
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion admin/javascript/LeftAndMain.js
Expand Up @@ -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.
Expand All @@ -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});

Expand Down

0 comments on commit a5a0853

Please sign in to comment.