Skip to content

Commit

Permalink
Update alert.js (#66)
Browse files Browse the repository at this point in the history
* Update alert.js

Prevent the modal from closing onConfirm and onCancel

* Add options to prevent an alert from closing
  • Loading branch information
alexcanana authored and Thomas Erbe committed Mar 8, 2019
1 parent 2d94bd6 commit f929e76
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/plugins/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down Expand Up @@ -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();
Expand All @@ -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();
}
Expand Down

0 comments on commit f929e76

Please # to comment.