logo       

Context-question: msg#00083

lang.ruby.rails.spinoffs

Subject: Context-question

As script.aculo.us does not seem to be available these days, Im asking my question
instead of looking it up. :-)

Im making an Ajax.Request, but would like to maintain the context in the onComplete-function.
Fx.
----------------- SNIP ------------------------
function MyClass(){
this.showMsg=function(msg){
alert(msg);
}
this.myRequest=function(){
var options={
onComplete:function(t){
this.showMsg("Request ended");
}
}
new Ajax.Request("http://myserver";, options);
this.showMsg("Request started");
}
}
var test=new MyClass();
test.myRequest();
--------------- SNAP ---------------------------

Its just a dummy function - but it fails because onComplete does no
have the right context and therefore can not use this.showMsg().

Any of you guys know how to maintain context?

Best Regards
Michael Krog


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise