Sha256: c43e02a14c9c74baefcd1293437ca852c45c9f5b8d555a8f73f82236377f004b

Contents?: true

Size: 1.19 KB

Versions: 7

Compression:

Stored size: 1.19 KB

Contents

# Copied from prototype-rails which is no longer maintained

module JavascriptHelper
  #   link_to_function("Show me more", nil, :id => "more_link") do |page|
  #     page[:details].visual_effect  :toggle_blind
  #     page[:more_link].replace_html "Show me less"
  #   end
  #     Produces:
  #       <a href="#" id="more_link" onclick="try {
  #         $(&quot;details&quot;).visualEffect(&quot;toggle_blind&quot;);
  #         $(&quot;more_link&quot;).update(&quot;Show me less&quot;);
  #       }
  #       catch (e) {
  #         alert('RJS error:\n\n' + e.toString());
  #         alert('$(\&quot;details\&quot;).visualEffect(\&quot;toggle_blind\&quot;);
  #         \n$(\&quot;more_link\&quot;).update(\&quot;Show me less\&quot;);');
  #         throw e
  #       };
  #       return false;">Show me more</a>
  #
  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] || '#'

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

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
fat_free_crm-0.14.2 app/helpers/javascript_helper.rb
fat_free_crm-0.14.1 app/helpers/javascript_helper.rb
fat_free_crm-0.15.0.beta.2 app/helpers/javascript_helper.rb
fat_free_crm-0.15.0.beta app/helpers/javascript_helper.rb
fat_free_crm-0.14.0 app/helpers/javascript_helper.rb
reduced_fat_crm-0.15.0.beta app/helpers/javascript_helper.rb
reduced_fat_crm-0.14.0 app/helpers/javascript_helper.rb