Forum: Ruby on Rails RE: button_to execute javascript function

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
torben.wolm (Guest)
on 2005-11-22 22:48
(Received via mailing list)
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.
This topic is locked and can not be replied to.