Module: JavascriptHelper
- Defined in:
- app/helpers/javascript_helper.rb
Overview
Copyright © 2008-2013 Michael Dvorkin and contributors.
Fat Free CRM is freely distributable under the terms of MIT license. See MIT-LICENSE file or www.opensource.org/licenses/mit-license.php
Copied from prototype-rails which is no longer maintained
Instance Method Summary collapse
-
#link_to_function(name, *args, &block) ⇒ Object
link_to_function(“Show me more”, nil, :id => “more_link”) do |page| page.visual_effect :toggle_blind page.replace_html “Show me less” end Produces: <a href=“#” id=“more_link” onclick=“try { $("details").visualEffect("toggle_blind"); $("more_link").update("Show me less"); } catch (e) { alert(‘RJS error:nn’ + e.toString()); alert(‘$("details").visualEffect("toggle_blind"); n$("more_link").update("Show me less");’); throw e }; return false;”>Show me more</a>.
Instance Method Details
#link_to_function(name, *args, &block) ⇒ Object
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 {
$("details").visualEffect("toggle_blind");
$("more_link").update("Show me less");
}
catch (e) {
alert('RJS error:\n\n' + e.toString());
alert('$(\"details\").visualEffect(\"toggle_blind\");
\n$(\"more_link\").update(\"Show me less\");');
throw e
};
return false;">Show me more</a>
28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/javascript_helper.rb', line 28 def link_to_function(name, *args, &block) = args..symbolize_keys function = block_given? ? update_page(&block) : args[0] || '' onclick = "#{"#{[:onclick]}; " if [:onclick]}#{function}; return false;" href = [:href] || '#' content_tag(:a, name, .merge(href: href, onclick: onclick)) end |