jquery.AreYouSure icon indicating copy to clipboard operation
jquery.AreYouSure copied to clipboard

Add a custom check

Open alrick opened this issue 11 years ago • 2 comments

Hi there!

Great plugin. Is there a way to customize the check of are you sure?

What I want :

if form is dirty
    send an alert
if form isn't dirty
    if custom function return true
        send an alert

Thanks!

alrick avatar Apr 17 '14 14:04 alrick

That's a good request. I'll need to think about the most elegant way of implementing this. It might be worth adding a custom function hook as you've suggested. e.g.

$('#myform').areYouSure({customCheck: function() {  if (rand > 0.5) return true; }});

If we go down this path, do you have any thoughts on the option name?

As for doing this in the current version: There is an existing hook to intercept dirty state changes and in theory you could say add the ".dirty" class back on the form. It should work, but it's a bit hacky.

Cheers,

Chris

codedance avatar Apr 23 '14 00:04 codedance

Hey Chris!

Thanks for the tips. customCheck isn't that bad ;)

alrick avatar Apr 29 '14 15:04 alrick