diff --git a/admin/javascript/LeftAndMain.Menu.js b/admin/javascript/LeftAndMain.Menu.js index 0f1c8a085f3..20a4da06a02 100644 --- a/admin/javascript/LeftAndMain.Menu.js +++ b/admin/javascript/LeftAndMain.Menu.js @@ -57,15 +57,20 @@ editPageItem[editPageItem.is('.current') ? 'show' : 'hide'](); - // update the menu links to reflect the page ID if the page has changed the URL. + // Update the menu links to reflect the page ID if the page has changed the URL. var currentID = $('.cms-content input[name=ID]').val(); - - // only handling the sub menu as the other items are global in context + var itemsWithPageContext = [ + '#Menu-CMSPageAddController', + '#Menu-CMSPageSettingsController', + '#Menu-CMSPageHistoryController', + '#Menu-CMSPageEditController' + ]; if(currentID) { - $(this).find("ul a").each(function(i, elem) { + var links = $(this).find(itemsWithPageContext.join(',')).find('a'); + links.each(function(i, elem) { var href = $(elem).attr("href").split('/'); href[href.length -1] = currentID; - + // Assumes that current ID will always be the last URL segment (and not a query parameter) $(elem).attr('href', href.join('/')); }); } diff --git a/admin/javascript/LeftAndMain.js b/admin/javascript/LeftAndMain.js index 70aa347496d..ab1622e4a78 100644 --- a/admin/javascript/LeftAndMain.js +++ b/admin/javascript/LeftAndMain.js @@ -70,7 +70,13 @@ self.redraw(); }); - $('.cms-edit-form').live('reloadeditform', function() { + $('.cms-edit-form').live('reloadeditform', function(e, data) { + // Simulates a redirect on an ajax response - just exchange the URL without re-requesting it + if(window.History.enabled) { + var url = data.xmlhttp.getResponseHeader('X-ControllerURL'); + if(url) window.history.replaceState({}, '', url); + } + self.redraw() }); @@ -222,6 +228,12 @@ self.redraw(); newContentEl.css('visibility', 'visible'); newContentEl.removeClass('loading'); + + // Simulates a redirect on an ajax response - just exchange the URL without re-requesting it + if(window.History.enabled) { + var url = xhr.getResponseHeader('X-ControllerURL'); + if(url) window.history.replaceState({}, '', url); + } self.trigger('afterstatechange', {data: data, status: status, xhr: xhr, element: newContentEl}); },