Recognizing DOM add for leave page naviation warning
away from a page without submitting. I am having issues when the page uses document.add to overwrite radio buttons and textboxes. Everything else works. What doesn't work is when the user clears a textbox or radio button. The way it gets cleared is with document.add. I want to include this segment of code on multiple pages, so it must be dynamic. Here is what I have so far:
- var warnMessage = "You have unsaved changes on this page!";
-
- $(document).ready(function() {
- $(document).live('change', ':input', function () {
- $('form*').add(function() {
- alert("wassup son");
- });
- window.onbeforeunload = function () {
- if (warnMessage != null) return warnMessage;
- }
- });
- //DOESN'T SHOW WARNING MESSAGE IF SUBMIT BUTTON IS PRESSED
- $('form').submit(function() {
- warnMessage = null;
- });
- });