Skip to content
This repository
Browse code

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...
commit a5a08530fc88ed0bc61cab9c0e794a76d24fbf63 1 parent 8d3d3a7
Ingo Schommer authored July 13, 2012

Showing 1 changed file with 10 additions and 1 deletion. Show diff stats Hide diff stats

  1. 11  admin/javascript/LeftAndMain.js
11  admin/javascript/LeftAndMain.js
@@ -287,7 +287,8 @@ jQuery.noConflict();
287 287
 
288 288
 				var self = this, h = window.History, state = h.getState(),
289 289
 					fragments = state.data.pjax || 'Content', headers = {},
290  
-					contentEls = this._findFragments(fragments.split(','));
  290
+					fragmentsArr = fragments.split(','),
  291
+					contentEls = this._findFragments(fragmentsArr);
291 292
 
292 293
 				// For legacy IE versions (IE7 and IE8), reload without ajax
293 294
 				// as a crude way to fix memory leaks through whole window refreshes.
@@ -297,6 +298,14 @@ jQuery.noConflict();
297 298
 					document.location.href = state.url;
298 299
 					return;
299 300
 				}
  301
+
  302
+				// If any of the requested Pjax fragments don't exist in the current view,
  303
+				// fetch the "Content" view instead, which is the "outermost" fragment
  304
+				// that can be reloaded without reloading the whole window.
  305
+				if(contentEls.length < fragmentsArr.length) {
  306
+					fragments = 'Content', fragmentsArr = ['Content'];
  307
+					contentEls = this._findFragments(fragmentsArr);					
  308
+				}
300 309
 				
301 310
 				this.trigger('beforestatechange', {state: state, element: contentEls});
302 311
 

0 notes on commit a5a0853

Please sign in to comment.
Something went wrong with that request. Please try again.