Module: ActionView::Helpers::PrototypeHelper::JavaScriptGenerator::GeneratorMethods

Defined in:
lib/jquery_for_rjs.rb

Instance Method Summary collapse

Instance Method Details

#hide(*ids) ⇒ Object



64
65
66
# File 'lib/jquery_for_rjs.rb', line 64

def hide(*ids)
  call "#{JQUERY_VAR}(\"#{jquery_ids(ids)}\").hide"
end

#insert_html(position, id, *options_for_render) ⇒ Object



41
42
43
44
45
46
# File 'lib/jquery_for_rjs.rb', line 41

def insert_html(position, id, *options_for_render)
  insertion = position.to_s.downcase
  insertion = 'append' if insertion == 'bottom'
  insertion = 'prepend' if insertion == 'top'
  call "#{JQUERY_VAR}(\"#{jquery_id(id)}\").#{insertion}", render(*options_for_render)
end

#jquery_id(id) ⇒ Object



72
73
74
# File 'lib/jquery_for_rjs.rb', line 72

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

#jquery_ids(ids) ⇒ Object



76
77
78
# File 'lib/jquery_for_rjs.rb', line 76

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

#remove(*ids) ⇒ Object



56
57
58
# File 'lib/jquery_for_rjs.rb', line 56

def remove(*ids)
  call "#{JQUERY_VAR}(\"#{jquery_ids(ids)}\").remove"
end

#replace(id, *options_for_render) ⇒ Object



52
53
54
# File 'lib/jquery_for_rjs.rb', line 52

def replace(id, *options_for_render)
  call "#{JQUERY_VAR}(\"#{jquery_id(id)}\").replaceWith", render(*options_for_render)
end

#replace_html(id, *options_for_render) ⇒ Object



48
49
50
# File 'lib/jquery_for_rjs.rb', line 48

def replace_html(id, *options_for_render)
  insert_html(:html, id, *options_for_render)
end

#show(*ids) ⇒ Object



60
61
62
# File 'lib/jquery_for_rjs.rb', line 60

def show(*ids)
  call "#{JQUERY_VAR}(\"#{jquery_ids(ids)}\").show"
end

#toggle(*ids) ⇒ Object



68
69
70
# File 'lib/jquery_for_rjs.rb', line 68

def toggle(*ids)
  call "#{JQUERY_VAR}(\"#{jquery_ids(ids)}\").toggle"
end