Module: LinkToFunctionHelper

Defined in:
lib/link_to_function_helper.rb

Instance Method Summary collapse

Instance Method Details

Puts the link_to_function back in a non-UJS way. Handy if you’re trying to save time doing a Rails 3 upgrade.



3
4
5
6
7
8
9
10
11
# File 'lib/link_to_function_helper.rb', line 3

def link_to_function(name, *args, &block)
   html_options = args.extract_options!.symbolize_keys

   function = block_given? ? update_page(&block) : args[0] || ''
   onclick = "#{"#{html_options[:onclick]}; " if html_options[:onclick]}#{function}; return false;"
   href = html_options[:href] || '#'

   (:a, name, html_options.merge(:href => href, :onclick => onclick))
end