Skip to content

Commit

Permalink
Make the delete sweetalert customisable per link using data attribute…
Browse files Browse the repository at this point in the history
…s and fallback default values.
  • Loading branch information
garethlawson committed May 24, 2017
1 parent 3ca429e commit 0c7d9f4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions public/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,18 @@
$(document).ready(function () {
$('.delete-link').on('click', function (e) {
e.preventDefault();
var confirmUrl = $(this).prop('href');
var confirmUrl = $(this).prop('href'),
title = $(this).data('confirm-title') || "Are you sure?",
text = $(this).data('confirm-text') || "This cannot be undone.",
btnText = $(this).data('confirm-btn-text') || "Yes, delete it!";

swal({
title: "Are you sure?",
text: "This cannot be undone.",
title: title,
text: text,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!"
confirmButtonText: btnText
}).then(function () {
console.log(confirmUrl);
window.location.href = confirmUrl;
Expand Down

0 comments on commit 0c7d9f4

Please sign in to comment.