0
這應該很簡單,但由於我是新手編程,特別是在JavaScript中,我無法弄清楚。初學javascript問題
比方說,我有以下的javascript代碼:
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();
}
}
我需要的是訪問變量updateElement從新的Ajax.Request的的onSuccess在初始化設置好的。我該怎麼做?