module ActionView::Helpers
Public Instance Methods
javascript_function(*args, &block)
click to toggle source
This function can be used to render rjs inline
<%= javascript_function
do |page|
page.replace_html :list, :partial => 'list', :object => @list
end %>
# File lib/jrails/javascript_helper.rb, line 78 def javascript_function(*args, &block) html_options = args.extract_options! function = args[0] || '' html_options.symbolize_keys! function = update_page(&block) if block_given? javascript_tag(function) end
jquery_id(id)
click to toggle source
# File lib/jrails/javascript_helper.rb, line 87 def jquery_id(id) id.to_s.count('#.*,>+~:[/ ') == 0 ? "##{id}" : id end
jquery_ids(ids)
click to toggle source
# File lib/jrails/javascript_helper.rb, line 91 def jquery_ids(ids) Array(ids).map{|id| jquery_id(id)}.join(',') end
link_to_function(name, *args, &block)
click to toggle source
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>
# File lib/jrails/javascript_helper.rb, line 62 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