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)
This commit is contained in:
Ingo Schommer 2012-07-13 10:19:24 +02:00
parent 8d3d3a7229
commit a5a08530fc

View File

@ -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});