This should be easy, but since I m new to programming, specially in javascript, I cannot figure it out.
Let s say I have the following javascript code:
var InjectClientValue = Class.create();
InjectClientValue.prototype = {
initialize: function( sourceElement, eventElement, updateElement ) {
this.sourceElement = $(sourceElement);
this.element = $(eventElement);
this.updateElement =$(updateElement)
this.element.observe( click ,this.onClick.bindAsEventListener(this));
},
onClick: function(event) {
new Ajax.Request(this.element.href+"/"+this.sourceElement.value, {
method: get ,
onSuccess: function(transport) {
//How do I access the instance variable updateElement in InjectClientValue_
//updateElement.update(transport.responseJSON.content);
}
});
event.stop();
}
}
What I need is to access the variable updateElement setted in initialize from the onSuccess of new Ajax.Request. How can I do it?