jquery.AreYouSure
jquery.AreYouSure copied to clipboard
Ignore if submitting via onclick()
Is there a way to ignore this popup warning if my save button is actually a div firing submit() onclick() ? Thanks!
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.
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"> <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?
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.
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.
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.