From 58dc3f1c2f42bfb0fadee7740fb871868db889ab Mon Sep 17 00:00:00 2001 From: leantony Date: Mon, 30 Apr 2018 10:14:18 +0300 Subject: [PATCH 1/2] confirm on delete. Move message to JS --- src/Buttons/RendersButtons.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Buttons/RendersButtons.php b/src/Buttons/RendersButtons.php index 0c8e97a..74737dc 100644 --- a/src/Buttons/RendersButtons.php +++ b/src/Buttons/RendersButtons.php @@ -226,7 +226,7 @@ protected function addDeleteButton(): GenericButton 'pjaxEnabled' => false, 'dataAttributes' => [ 'method' => 'DELETE', - 'confirm' => 'Sure?', + 'trigger-confirm' => true, 'pjax-target' => '#' . $this->id ], 'url' => function ($gridName, $item) { @@ -412,4 +412,4 @@ protected function editToolbarButton(string $button, array $properties) $instance->{$k} = $v; } } -} \ No newline at end of file +} From 207561068b71abffc0304c54d2263b63c03b20a3 Mon Sep 17 00:00:00 2001 From: leantony Date: Mon, 30 Apr 2018 10:17:20 +0300 Subject: [PATCH 2/2] update confirmation message handler on ajax action --- src/resources/assets/js/grid.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/resources/assets/js/grid.js b/src/resources/assets/js/grid.js index ed24ebc..2dffa43 100644 --- a/src/resources/assets/js/grid.js +++ b/src/resources/assets/js/grid.js @@ -39,7 +39,9 @@ var _grids = _grids || {}; // since our refs are data-remote or class with data-remote, we need to loop element.each(function (i, obj) { obj = $(obj); - var confirmation = obj.data('confirm'); + // confirmation + var confirmation = obj.data('trigger-confirm'); + var confirmationMessage = obj.data('confirmation-msg') || 'Are you sure?'; // check if we need to refresh any pjax container var pjaxContainer = obj.data('pjax-target'); // check if we need to force a page refresh. will override shouldPjax @@ -55,7 +57,7 @@ var _grids = _grids || {}; e.preventDefault(); // check for a confirmation message if (confirmation) { - if (!confirm(confirmation)) { + if (!confirm(confirmationMessage)) { return; } }