On 2 oct, 21:19, rfd <[EMAIL PROTECTED]> wrote:
> Hi ,
>
> I have been trying to extend prototype's DOM extensions to a
> collection of radio button inputs with no success whatsoever.
>
> Here is the code:
> --------------------------------------------------
> var profiles = Form.getInputs("Form1", "radio", "supporter_id");
>
> profiles.each ( function(node)
> {
> Event.observe ( node, 'click', function ()
> {
>
> var tds = this.up(1).immediateDescendants();
>
> Cookie.set("test", 'FirstName='+tds[3].innerHTML
> +'&LastName='+tds[4].innerHTML, 1);
>
> alert(Cookie.get("test"));
>
> return false;
>
> },false );});
>
> -------------------------------------------------------
>
Like Rob said, you should use 'node.up' instead of 'this.up' as the
DOMElement (node) is passed in your iteration function, and is thus
available because of closures in Javascript.
Another way would be to bind the event function with the node element.
I.e. : Event.observe( node, 'click', function() { .... }.bind(node),
false );
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---