I am using the following for a delete button and although I get the confirm message, if I click cancel it still goes through with it:
<a onclick="return confirm('are you sure?')" class="btn btn-default btn-sm deleteList" href="#" list_id="1467" title="Delete your list: listName">Delete</a>
Anything obvious?
UPDATE:
This is attached to a jquery click function, so if the cancel stops the link following through, how can I prevent the click handler from firing?
UPDATE 2
Also tried at start of click handler but same problem:
$('.deleteList').on('click', function(e) {
confirm('are you sure?');
var list_id = $(this).attr("list_id");
$.ajax({
context: this,
type: "POST",
url: '/ajax/actions/deleteList.php?listId=' + list_id,
success: function (data) {
var d = $.now();
window.location.href = "/pages/dashboard?listDelete=" + d + "#mylists";
}
}); // End .ajax
e.preventDefault();
});