You know the feeling: You''re new to the event model(s) and you lose track of things easily. :-) Inside the constructor function for a JS class I dynamically add an <a> element. I then use observe() to bind an event-handling function for ''click''. Works fine that far. The handler gets control on click events. But how do I get access to the instantiated object of the class within that handler? I can use Event.element(event) to get the <a> element, but how do I get the JS object that established the handler? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
What timing! The Porteneuve book arrived 30 minutes ago and had the
answer. FYI, here''s the observe(0) call that did the trick:
this.control.closeLink.observe(''click'',this.close.bindAsEventListener(this,this));
1. Use of bindAsEventListener()
2. Passing ''this'' as its second argument.
On Apr 9, 10:21 am, Doug Kaye
<DougK...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> You know the feeling: You''re new to the event model(s) and you
lose
> track of things easily. :-)
>
> Inside the constructor function for a JS class I dynamically add an
> <a> element. I then use observe() to bind an event-handling function
> for ''click''. Works fine that far. The handler gets
control on click
> events. But how do I get access to the instantiated object of the
> class within that handler? I can use Event.element(event) to get the
> <a> element, but how do I get the JS object that established the
> handler?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Doug Kaye wrote:> What timing! The Porteneuve book arrived 30 minutes ago and had the > answer. FYI, here''s the observe(0) call that did the trick: > > > this.control.closeLink.observe(''click'',this.close.bindAsEventListener(this,this)); > > 1. Use of bindAsEventListener() > > 2. Passing ''this'' as its second argument. >And you don''t even need to pass this as the second parameter. You can already access the object using the "this" keyword inside the close function. Even simpler. - Ken --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---