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,
torben
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Damon H.
Sent: 22. november 2005 20:38
To: [email protected]
Subject: [Rails] button_to execute javascript function
Ok, I know this has to be EXTREMELY simple, so please excuse the
ignorance.
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.
~d