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

Defined in:
lib/jquery/jquery.rb

Instance Method Summary collapse

Instance Method Details

#hide(*ids) ⇒ Object



112
113
114
# File 'lib/jquery/jquery.rb', line 112

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

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



89
90
91
92
93
94
# File 'lib/jquery/jquery.rb', line 89

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



120
121
122
# File 'lib/jquery/jquery.rb', line 120

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

#jquery_ids(ids) ⇒ Object



124
125
126
# File 'lib/jquery/jquery.rb', line 124

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

#remove(*ids) ⇒ Object



104
105
106
# File 'lib/jquery/jquery.rb', line 104

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

#replace(id, *options_for_render) ⇒ Object



100
101
102
# File 'lib/jquery/jquery.rb', line 100

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



96
97
98
# File 'lib/jquery/jquery.rb', line 96

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

#show(*ids) ⇒ Object



108
109
110
# File 'lib/jquery/jquery.rb', line 108

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

#toggle(*ids) ⇒ Object



116
117
118
# File 'lib/jquery/jquery.rb', line 116

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