Hi...
I'm trying to write object-oriented style javascript as follows: ----------------------------- function HtmlFormUtil(formId){ this.formId=formId; this.dirtyInputs=new Array(); } HtmlFormUtil.prototype.trackForChanges=function(){ $(":input","#"+this.formId).change(function(){ this.dirtyInputs[this.dirtyInputs.length]=$(this); }); } HtmlFormUtil.prototype.isDirty=function(){ return this.dirtyInputs.length > 0; } ------------------------------- The intention is to use it to track any changes to the form fields... and warn user on window unload, if there's any dirty inputs (i.e form value has changed) Unfortunately, the code above doesnt work... because in "this.dirtyInputs[....]", the "this" keyword refers to the element that has the value changed (i.e. jquery object), and not 'this instance of HtmlFormUtil'. Has anyone ever done this before? What is the best way to solve my problem above? Thanks in advance for the help! -- Best regards, WiB