From f929e76a9e59d631867b0d0246a34a6811317704 Mon Sep 17 00:00:00 2001 From: alex canana Date: Fri, 8 Mar 2019 23:51:22 +0100 Subject: [PATCH] Update alert.js (#66) * Update alert.js Prevent the modal from closing onConfirm and onCancel * Add options to prevent an alert from closing --- src/plugins/alert.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/plugins/alert.js b/src/plugins/alert.js index 0d48fed..f435847 100644 --- a/src/plugins/alert.js +++ b/src/plugins/alert.js @@ -39,7 +39,9 @@ class Alert extends Modal { style: 'card', parent: document.body, showHeader: true, + closeOnConfirm: true, destroyOnConfirm: true, + closeOnCancel: true, destroyOnCancel: true, onConfirm: function(e) {}, onCancel: function(e) {} @@ -109,7 +111,9 @@ class Alert extends Modal { confirmButton.addEventListener('click', e => { this.onConfirm(e); - this.close(); + if(this.option('closeOnConfirm')) { + this.close(); + } if(this.option('destroyOnConfirm')) { this.destroy(); @@ -131,8 +135,10 @@ class Alert extends Modal { cancelButton.addEventListener('click', e => { this.onCancel(e); - this.close(); - + if(this.option('closeOnCancel')) { + this.close(); + } + if(this.option('destroyOnCancel')) { this.destroy(); }