Hi all
I''m new to Prototype, and am stuck at trying to bind an on click event-
listener to some table rows.
I have normal table (don''t worry, it IS tabular data).
I would like a certain function to fire when rows with a specific
className is clicked, so I do this:
var theRows = $$(''tr.details'');
Now, I then try to use the ''each'' function,like this:
trs.each(Event.observe(Element,''onclick'',myFunction('''')));
Obviously wrong ...
I''ve digged through the api-docs, but can''t find the correct
way to do
this.
Any ideas?
Best regards
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
from the archive that is my gmail inbox...
Event.observe(oneElement , ''click'', function(){
this.one_method()
}.bind(this));
On Nov 8, 2007 5:13 PM, Martin
<stenderdk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> Hi all
>
> I''m new to Prototype, and am stuck at trying to bind an on click
event-
> listener to some table rows.
>
> I have normal table (don''t worry, it IS tabular data).
> I would like a certain function to fire when rows with a specific
> className is clicked, so I do this:
> var theRows = $$(''tr.details'');
>
> Now, I then try to use the ''each'' function,like this:
>
trs.each(Event.observe(Element,''onclick'',myFunction('''')));
> Obviously wrong ...
>
> I''ve digged through the api-docs, but can''t find the
correct way to do
> this.
>
> Any ideas?
>
> Best regards
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
You were nearly there... If you''re using the newest release of
prototype (v1.6.0), you could use a syntax like this:
$$(''tr.details'').each(function(row) {
row.observe(''click'',
myFunction.curry(''''));
});
not sure about the .curry() part, but it should work...
Greetz
On Nov 8, 11:13 pm, Martin
<stende...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi all
>
> I''m new to Prototype, and am stuck at trying to bind an on click
event-
> listener to some table rows.
>
> I have normal table (don''t worry, it IS tabular data).
> I would like a certain function to fire when rows with a specific
> className is clicked, so I do this:
> var theRows = $$(''tr.details'');
>
> Now, I then try to use the ''each'' function,like this:
>
trs.each(Event.observe(Element,''onclick'',myFunction('''')));
> Obviously wrong ...
>
> I''ve digged through the api-docs, but can''t find the
correct way to do
> this.
>
> Any ideas?
>
> Best regards
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
If you need to run the same function each time, but sending the
relevant tr element,
$$(''tr.details'').invoke(''observe'',
''click'', function(e)
{
myFunction(this); // this refers to the tr you clicked on
});
On Nov 9, 4:15 pm, Wizz
<woutaw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> You were nearly there... If you''re using the newest release of
> prototype (v1.6.0), you could use a syntax like this:
>
> $$(''tr.details'').each(function(row) {
> row.observe(''click'',
myFunction.curry(''''));
>
> });
>
> not sure about the .curry() part, but it should work...
>
> Greetz
>
> On Nov 8, 11:13 pm, Martin
<stende...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > Hi all
>
> > I''m new to Prototype, and am stuck at trying to bind an on
click event-
> > listener to some table rows.
>
> > I have normal table (don''t worry, it IS tabular data).
> > I would like a certain function to fire when rows with a specific
> > className is clicked, so I do this:
> > var theRows = $$(''tr.details'');
>
> > Now, I then try to use the ''each'' function,like
this:
> >
trs.each(Event.observe(Element,''onclick'',myFunction('''')));
> > Obviously wrong ...
>
> > I''ve digged through the api-docs, but can''t find the
correct way to do
> > this.
>
> > Any ideas?
>
> > Best regards
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Thank you all - just the examples I needed to move on! redheat: nice and lean - thanks :-) Best regards Martin On Nov 10, 10:26 am, redheat <ecouch...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> If you need to run the same function each time, but sending the > relevant tr element, > > $$(''tr.details'').invoke(''observe'', ''click'', function(e) > { > myFunction(this); // this refers to the tr you clicked on > > }); > > On Nov 9, 4:15 pm, Wizz <woutaw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > You were nearly there... If you''re using the newest release of > > prototype (v1.6.0), you could use a syntax like this: > > > $$(''tr.details'').each(function(row) { > > row.observe(''click'', myFunction.curry('''')); > > > }); > > > not sure about the .curry() part, but it should work... > > > Greetz > > > On Nov 8, 11:13 pm, Martin <stende...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi all > > > > I''m new to Prototype, and am stuck at trying to bind an on clickevent- > > > listener to some table rows. > > > > I have normal table (don''t worry, it IS tabular data). > > > I would like a certain function to fire when rows with a specific > > > className is clicked, so I do this: > > > var theRows = $$(''tr.details''); > > > > Now, I then try to use the ''each'' function,like this: > > > trs.each(Event.observe(Element,''onclick'',myFunction(''''))); > > > Obviously wrong ... > > > > I''ve digged through the api-docs, but can''t find the correct way to do > > > this. > > > > Any ideas? > > > > Best regards--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---