I have a JS object that in pseudo code is doing this:
function myObj {
// in constructor
... initialise vars
... call $.Ajax to fetch view from server
function AjaxCallBack() {
// load the DOM with the HTML result
$('#dialog').html(ajax.result);
// try to register a change handler
$("#dialog :input").change(this.formChangeEvent);
}
this.formChangeEvent = function(){
... do stuff
}
}
The problem is that in the AjaxCallBack, 'this' is not myObj object, but rather the 'window' object and can't resolve the function
The only way I've been able to get around this problem is to have the receiver of the object call back into a separate function of myObj and register the event
objInstance = new myObj();
objInstance.registerEventHandler();
I've tried a few other things, but I'm obviously missing something basic.