More specific entwine rule for delete alert in GridField

The rule didn't apply in Firefox because of how it handles specificity,
so made it a bit more specific (added "button" and ".action")
This commit is contained in:
Ingo Schommer 2013-08-16 15:24:50 +02:00
parent d325551079
commit 02cc662aaf
3 changed files with 12 additions and 2 deletions

View File

@ -200,6 +200,15 @@
* Function: onclick
*/
onclick: function(e) {
// Confirmation on delete.
if(
this.hasClass('gridfield-button-delete')
&& !confirm(ss.i18n._t('TABLEFIELD.DELETECONFIRMMESSAGE'))
) {
e.preventDefault();
return false;
}
if(!this.is(':disabled')) {
this.parents('form').trigger('submit', [this]);
}

View File

@ -349,7 +349,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler {
if($canDelete) {
$actions->push(FormAction::create('doDelete', _t('GridFieldDetailForm.Delete', 'Delete'))
->setUseButtonTag(true)
->addExtraClass('ss-ui-action-destructive'));
->addExtraClass('ss-ui-action-destructive action-delete'));
}
}else{ // adding new record

View File

@ -135,7 +135,8 @@
}
});
$('.ss-gridfield .action.gridfield-button-delete, .cms-content-actions .ss-ui-action-destructive .ui-button-text').entwine({
// Covers both tabular delete button, and the button on the detail form
$('.ss-gridfield .Actions .action.gridfield-button-delete, .cms-edit-form .Actions button.action.action-delete').entwine({
onclick: function(e){
if(!confirm(ss.i18n._t('TABLEFIELD.DELETECONFIRMMESSAGE'))) {
e.preventDefault();