Here is my object:
Now when I attempt to leave the window, I receive "TypeError: this.confirmExit is not a function".Code:function formWatcher(form, options) { this.form = $(form); console.log(this.form); this.submitted = false; this.formcontents = this.form.serialize(); this.options = { "formMessage" : "If you leave this page now, your changes will not be saved.", "ajaxMessage" : "This page is still processing your request.", "requireSubmit" : false, "exempt" : [] }; this.form.bind('submit', function() { submitted = true; }); $.each(this.options["exempt"], function(e_index, e_value) { this.exemptElement(e_value); }); $(window).unload(function(){ this.confirmExit(this); }); this.exemptElement = function(element) { if(element) { element.click(function() { this.submitted = true; }); } }; this.confirmExit = function(ev) { this.newcontents = this.form.serialize(); if (((this.formcontents != this.newcontents) || this.options.requireSubmit) && !(this.submitted)) { ev.stop(); ev.returnValue = this.options.formMessage; } else { return true; } }; };
Please help!



Reply With Quote

Bookmarks