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

This commit is contained in:
Ingo Schommer 2012-03-12 13:30:17 +01:00
parent e5ade1ba12
commit 51ff4004d1

View File

@ -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