Module: ActionView::Helpers::JavaScriptHelper

Defined in:
lib/jquery_for_rjs.rb

Instance Method Summary collapse

Instance Method Details

#javascript_function(*args, &block) ⇒ Object

This function can be used to render rjs inline

<%= javascript_function do |page|

page.replace_html :list, :partial => 'list', :object => @list

end %>



13
14
15
16
17
18
19
20
# File 'lib/jquery_for_rjs.rb', line 13

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) ⇒ Object



22
23
24
# File 'lib/jquery_for_rjs.rb', line 22

def jquery_id(id)
  id.to_s.count('#.*,>+~:[/ ') == 0 ? "##{id}" : id
end

#jquery_ids(ids) ⇒ Object



26
27
28
# File 'lib/jquery_for_rjs.rb', line 26

def jquery_ids(ids)
  Array(ids).map{|id| jquery_id(id)}.join(',')
end