On 8/24/07, Walter Lee Davis <[EMAIL PROTECTED]> wrote:
> I have $$('a.citation'), and I am using invoke to run through all of
> them. I know I need to add bindAsEventListener in there somewhere, but
> what is the reference to my "looped" object that I pass back to it?
>
> $$('a.citation').invoke('observe','click',cit_this.bindAsEventListener()
> );

If you're trying to assign an event handler to all the citation links,
you can do it like so:

$$('a.citation').invoke('observe', 'click', eventHandler);

You don't need to call bindAsEventListener. How you get the element
that triggered the event once inside the event handler depends on
whether you're using 1.5 or 1.6.

1.5 style:
function eventHandler(evt) {
  var el = Event.element(evt);
  // do stuff with el
}

1.6 style:
function eventHandler(evt) {
  var el = this;  // sweet! 'this' is mapped to the element that fired
the event automatically
  // do stuff with el
}

I may have missed the point of what you're actually trying to do, and
if so, I apologize.

:Dan Dorman

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to