oops!

$('element1','element2').invoke('observe', 'change',
this.EventHandlerFunction.bind(this));

cf.: http://prototypejs.org/api/enumerable/invoke 
http://prototypejs.org/api/element/observe

On Jan 31, 2:24 am, Tobie Langel <[EMAIL PROTECTED]> wrote:
> $('element1','element2').each(function(e) {
>   e.onchange = this.EventHandlerFunction.bind(this);
>
> }.bind(this));
>
> However, I'd strongly advise using Event.observe instead like so:
>
> $('element1','element2').invoke('change',
> this.EventHandlerFunction.bind(this));
>
> Best,
>
> Tobie
>
> On Jan 31, 1:57 am, kaydub <[EMAIL PROTECTED]> wrote:
>
> > Greetings;
>
> > Inside the init() for my class I am assigning event handlers and want
> > to use the same handler function for 2 separate elements so I am using
> > the following code:
>
> > $('element1','element2').onchange =
> > this.EventHandlerFunction.bindAsEventListener(this);
>
> > I assumed since I can chain elements inside the $() function that the
> > functionality would allow for this. It doesnt.
>
> > It doesn't catch the event for either element at all.
>
> > When I seperate the code into 2 lines and assign the function to each
> > element independently it works fine:
>
> > $('element1').onchange =
> > this.EventHandlerFunction.bindAsEventListener(this);
> > $('element2').onchange =
> > this.EventHandlerFunction.bindAsEventListener(this);
>
> > I dont have a problem with doing that but I would much prefer to use
> > the former to remain consistent with $().
>
> > I havent looked much into the source to find where it is stopping but
> > is this a bug?? Should I report it?
>
> > Thanks ahead of time,
> > Kev
--~--~---------~--~----~------------~-------~--~----~
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