|
|
Re: Context-question: msg#00084
lang.ruby.rails.spinoffs
|
Subject: |
Re: Context-question |
Sorry.
Im acting like its a crappy monday. I forgot '.bind(this)' is usable for
this matter.
-Michael
Michael Krog wrote:
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
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@xxxxxxxxxxxxxxxx
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
|
|