From 51ff4004d1b48955baded2bb0d08ee5772193448 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 12 Mar 2012 13:30:17 +0100 Subject: [PATCH] ENHANCEMENT Allowing ajax responses on CMS form submissions to "break out" of the form element they were triggered through, by looking for existence of ".cms-content" node in response --- admin/javascript/LeftAndMain.Content.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/admin/javascript/LeftAndMain.Content.js b/admin/javascript/LeftAndMain.Content.js index 69c5b64ed..2852be827 100644 --- a/admin/javascript/LeftAndMain.Content.js +++ b/admin/javascript/LeftAndMain.Content.js @@ -197,7 +197,16 @@ */ submitForm_responseHandler: function(oldForm, data, status, xmlhttp, origData) { if(status == 'success') { - var form = this.replaceForm(oldForm, data); + var form, newContent = $(data); + + // HACK If response contains toplevel panel rather than a form, replace it instead. + // For example, a page view shows tree + edit form. Deleting this page redirects to + // the "pages" overview, which doesn't have a separate tree panel. + if(newContent.is('.cms-content')) { + $('.cms-content').replaceWith(newContent); + } else { + form = this.replaceForm(oldForm, newContent); + } if(typeof(Behaviour) != 'undefined') Behaviour.apply(); // refreshes ComplexTableField