From b242bfb3dab29db1682ed929c0b1d55dbe792f5a Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 2 Mar 2012 20:27:13 +0100 Subject: [PATCH] BUGFIX Include GET parameters of current URL in GridField on ajax reloads to retain view state --- admin/javascript/LeftAndMain.js | 3 +++ javascript/GridField.js | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/admin/javascript/LeftAndMain.js b/admin/javascript/LeftAndMain.js index 06b5d6b66..74e8a05a3 100644 --- a/admin/javascript/LeftAndMain.js +++ b/admin/javascript/LeftAndMain.js @@ -387,6 +387,9 @@ jQuery.noConflict(); */ $('.cms .ss-gridfield').entwine({ showDetailView: function(url) { + // Include any GET parameters from the current URL, as the view state might depend on it. + // For example, a list prefiltered through external search criteria might be passed to GridField. + if(window.location.search) url += window.location.search; $('.cms-container').entwine('ss').loadPanel(url); } }); diff --git a/javascript/GridField.js b/javascript/GridField.js index 24f76ec1f..eb42af07a 100644 --- a/javascript/GridField.js +++ b/javascript/GridField.js @@ -11,6 +11,12 @@ if(!ajaxOpts.data) ajaxOpts.data = []; ajaxOpts.data = ajaxOpts.data.concat(data); + // Include any GET parameters from the current URL, as the view state might depend on it. + // For example, a list prefiltered through external search criteria might be passed to GridField. + if(window.location.search) { + ajaxOpts.data = window.location.search.replace(/^\?/, '') + '&' + $.param(ajaxOpts.data); + } + form.addClass('loading'); $.ajax($.extend({}, {