christoph.hautzinger-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2007-Apr-15 16:40 UTC
Call function from outer class in an anonyme function
hello, i have a little problem...
in need to call a method of an outer class within a anonyme function.
here is my code example:
-- snip
var Test = Class.create();
Test.prototype = {
test: function() {
alert(''test!'');
}
query: function() {
new Ajax.Request(...url..., {
onSuccess: function(transport, json) {
// call Test.test() here???
Test.test();
}
});
}
}
-- snip
I tried to write a method Test.queryOnSuccess(transport, json) which
is located in the same class and overwrites the anonyme function, but
this didn''t work either.
Can anybody tell me how to do this?
Thank you
Regards Christoph Hautzinger
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2007-Apr-15 16:53 UTC
Re: Call function from outer class in an anonyme function
Hey Christoph,
Classic binding issue:
Test.prototype = {
test: function() {
alert(''test!'');
}
query: function() {
new Ajax.Request(...url..., {
onSuccess: function(transport, json) {
this.test();
}.bind(this)
});
}
}
--
Christophe Porteneuve a.k.a. TDD
"[They] did not know it was impossible, so they did it." --Mark Twain
Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---