serialization - using jquery serialize/window.onbeforeunload to check for a dirty form and stop user from leaving is not working in browsers besides IE -
serialization - using jquery serialize/window.onbeforeunload to check for a dirty form and stop user from leaving is not working in browsers besides IE -
i'm using next code warn users if leaving form without saving. works in ie in firefox, chrome , safari gives me warning every time regardless of whether or not form changed. works in ie , simple, hope can working all, or @ to the lowest degree more browsers. (needtoconfirm used stop warning on buttons such "save" button)
<script type="text/javascript"> var form_clean; var needtoconfirm = true; // serialize clean form $(function() { form_clean = $("form").serialize(); }); // compare clean , dirty form before leaving window.onbeforeunload = function (e) { var form_dirty = $("form").serialize(); if (needtoconfirm) { if(form_clean != form_dirty) { homecoming 'you have unsaved work.'; } else { window.onbeforeunload = null; } } }; </script>
the form huge - coldfusion legacy system. not w3c compliant , that's i'm trying prepare go along may or may not affecting this. starts with:
<cfform method="post" name="editform" id="editform" action="#cgi.script_name#"> <input type="hidden" name="postback" value="yes">
and contains variety of inputs , cfinputs.
jquery serialization coldfusion onbeforeunload cfform
Comments
Post a Comment