Module: ActionView::Helpers::JavaScriptHelper

Defined in:
lib/jrails.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 %>



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

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



21
22
23
# File 'lib/jrails.rb', line 21

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

#jquery_ids(ids) ⇒ Object



25
26
27
# File 'lib/jrails.rb', line 25

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