I've got a plugin that's got element types. I've got a Transaction
element that I need the user to confirm before saving.
I've tried to use the jQuery that comes with craft:
$('form').submit(function(e) {
var txt;
if (confirm("Are you sure you want to save?")) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
return false;
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
}
console.log(txt);
})
but the element still saves on the edit page.
How can I prevent the element from saving if the user clicks cancel.