codedance / jquery.AreYouSure

A light-weight jQuery "dirty forms" Plugin - it monitors html forms and alerts users to unsaved changes if they attempt to close the browser or navigate away from the page. (Are you sure?)
507 stars 145 forks source link

Toggle button tag rather than submit input breaks change event #72

Closed rdejuana closed 12 months ago

rdejuana commented 9 years ago

If i use a button instead of an submit input, the change event will stop working.

I use the code below, which is very similar to your example.

change = () ->
    $form = $(this)
    $button = $form.find('button')
    if $form.hasClass('dirty')
      $button.removeAttr('disabled');
    else
      $button.attr('disabled', 'disabled');

$('form').areYouSure({change: change})

My form is pretty standard form with some radio buttons. If i toggle the radio buttons and turn off the removeAttr line, it will work fine. When I reenable it, it will work the first time and never fire again.

Any idea what is wrong?

codedance commented 9 years ago

Is this related to the pull request #73 ? Did this change fix the issue?

rdejuana commented 9 years ago

I think it fixed it. I have only tested it in chrome so far. I'm not too sure how your code works, but the exclusions in your fields selector seemed to imply the fix to my issue.

I know the some browsers (cough...ie..cough) had issues before with the button tag, but its been a while since i have seen them.