RE: button_to execute javascript function


I think you can use one of:

<%= link_to_function “Add Row”, “addRow()” %>

<%= tag “input”, { “type” => “button”, “value” => “Add Row”, “onclick”
=> “addRow()” } %>

<%= button_to “Add Row”, “javascript:addRow()” %>

Best regards,


-----Original Message-----
From: removed_email_address@domain.invalid 

[mailto:removed_email_address@domain.invalid] On Behalf Of Damon H.
Sent: 22. november 2005 20:38
To: removed_email_address@domain.invalid
Subject: [Rails] button_to execute javascript function

Ok, I know this has to be EXTREMELY simple, so please excuse the 


However, I want the button_to method to execute some external 

javascript function I have predefined called “addRow()” when the user
clicks the button.

I see all these examples of button_to .... :confirm => "Are you sure?", 

but that is the ONLY example I see for button_to html_options.

I attempted this button_to ....:onclick => "addRow()", but it appends 

this to the url ?onclick=addRow().

Anyone? Anyone?

Show me just how dumb I am this afternoon.
It won't hurt my feelings in the least.

Thanks in advance.