Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Javascript Link Helper (See related posts)

Ruby on Rails helper to create a link tag to 'name' wich execute the 'javascript' statement onclick event. The last both parameters are the same as for link_to.

Helper para o Ruby on Rails para criar um tag de link associado ao 'name' que executa o código 'javascript' no evento onclick. Os últimos dois parâmetros são os mesmos utilizados no link_to

	def javascript_link_to(name, javascript, html_options = nil, *parameters_for_method_reference)
		options = [ :action => @params["action"] ]
		html_options = { :onclick => javascript+"return false" }
		link_to(name, options, html_options, *parameters_for_method_reference)
	end

Comments on this post

zsombor posts on Sep 08, 2006 at 17:06
How is this different than link_to_function already provided by rails?

You need to create an account or log in to post comments to this site.


Click here to browse all 4834 code snippets

Related Posts