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

Ignore if submitting via onclick()

Open davidangel opened this issue 11 years ago • 5 comments

Is there a way to ignore this popup warning if my save button is actually a div firing submit() onclick() ? Thanks!

davidangel avatar Mar 05 '13 16:03 davidangel

You can manually remove the "dirty" class on the form via your onclick event before attempting to navigate away. e.g.

$myForm.removeClass("dirty"); // move to next page.

If you can provide an example, I can try and think if there is an automatic way to code around your use-case.

codedance avatar Mar 17 '13 12:03 codedance

This bit of code works:

<div class="action_button" onclick="document.forms.lead_edit.className='';document.forms.lead_edit.action='/frontend_dev.php/leads/create';document.forms.lead_edit.submit()"><img src="/images/disk.png">&nbsp;<span class="action_button_label">Save</span></div>

BUT, when the form that's submitted fails validation and is refreshed, this code doesn't seem to work, and the Save button throws up the AreYouSure warning. Any thoughts on this?

davidangel avatar Mar 20 '13 14:03 davidangel

You'll need to use code like:

$("#myForm").removeClass('dirty')

on your click handler. Give that a go and let me know if results are any better.

codedance avatar Mar 21 '13 11:03 codedance

Just ran into this same issue. Chrome (36) was prompting me about a dirty form on a form that was being submitted programmatically (document.form.submit()) but Firefox (31) didn't have any problem with it. Adding in $(#form).removeClass("dirty") right before the from was submitted fixed it from Chrome.

TheBrockEllis avatar Aug 29 '14 13:08 TheBrockEllis

I thinking it might be worth documenting this. It seems to have come up a few times. Chrome must not fire the submit event at the same time when it's called form code.

I'll change the status and assign it to the next milestone.

Thanks for the feedback.

codedance avatar Aug 31 '14 22:08 codedance