mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
70207b0c98
commit
556090ccfa
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user