Generic “cancel” button behaviour with History.back()

Used in “add page” dialog. See https://github.com/silverstripe/silverstripe-cms/pull/793 for context
This commit is contained in:
Ingo Schommer 2013-11-22 12:45:39 +01:00
parent 70207b0c98
commit 556090ccfa

View File

@ -217,6 +217,21 @@
}
});
/**
* If we've a history state to go back to, go back, otherwise fall back to
* submitting the form with the 'doCancel' action.
*/
$('.cms-edit-form .Actions input.action[type=submit].ss-ui-action-cancel, .cms-edit-form .Actions button.action.ss-ui-action-cancel').entwine({
onclick: function(e) {
if (History.getStateByIndex(1)) {
History.back();
} else {
this.parents('form').trigger('submit', [this]);
}
e.preventDefault();
}
});
/**
* Hide tabs when only one is available.
* Special case is actiontabs - tabs between buttons, where we want to have