hello I have a problem with the following code : var Test = Class.create({ data:"Test", initialize: function() { this.t2 = new Test2(this.callt1); }, callt1: function(){ alert(this.data); } }); var Test2 = Class.create({ data: "Test2", initialize: function(callback) { this.callback=callback; }, callt2: function(){ this.callback(); } }); var t = new Test(); t.t2.callt2(); I get "Test2" but I''m wait for "Test". I think it is not a bug but how can I do to obtain "Test" Thomas --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
That''s quite confusing : ) You obtain "Test" like so: t.t2.callback.call(t) - kangax On May 10, 1:52 pm, Thomas <peti...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hello > > I have a problem with the following code : > > var Test = Class.create({ > data:"Test", > initialize: function() { > this.t2 = new Test2(this.callt1); > }, > callt1: function(){ > alert(this.data); > } > > }); > > var Test2 = Class.create({ > data: "Test2", > initialize: function(callback) { > this.callback=callback; > }, > callt2: function(){ > this.callback(); > } > > }); > > var t = new Test(); > > t.t2.callt2(); > > I get "Test2" but I''m wait for "Test". I think it is not a bug but how > can I do to obtain "Test" > > Thomas--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Wow, is this a test? You can also get "Test" by binding your callback to Test var Test = Class.create({ data:"Test", initialize: function() { this.t2 = new Test2(this.callt1.bind(this)); }, callt1: function(){ alert(this.data); } }); On May 10, 1:15 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> That''s quite confusing : ) > > You obtain "Test" like so: > t.t2.callback.call(t) > > - kangax > > On May 10, 1:52 pm, Thomas <peti...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > hello > > > I have a problem with the following code : > > > var Test = Class.create({ > > data:"Test", > > initialize: function() { > > this.t2 = new Test2(this.callt1); > > }, > > callt1: function(){ > > alert(this.data); > > } > > > }); > > > var Test2 = Class.create({ > > data: "Test2", > > initialize: function(callback) { > > this.callback=callback; > > }, > > callt2: function(){ > > this.callback(); > > } > > > }); > > > var t = new Test(); > > > t.t2.callt2(); > > > I get "Test2" but I''m wait for "Test". I think it is not a bug but how > > can I do to obtain "Test" > > > Thomas--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---