Class: ActionView::Helpers::JavaScriptElementProxy

Inherits:
JavaScriptProxy show all
Defined in:
lib/action_view/helpers/prototype_helper.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(generator, id) ⇒ JavaScriptElementProxy

Returns a new instance of JavaScriptElementProxy.



1135
1136
1137
1138
# File 'lib/action_view/helpers/prototype_helper.rb', line 1135

def initialize(generator, id)
  @id = id
  super(generator, "$(#{id.to_json})")
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActionView::Helpers::JavaScriptProxy

Instance Method Details

#[](attribute) ⇒ Object

Allows access of element attributes through attribute. Examples:

page['foo']['style']                  # => $('foo').style;
page['foo']['style']['color']         # => $('blank_slate').style.color;
page['foo']['style']['color'] = 'red' # => $('blank_slate').style.color = 'red';
page['foo']['style'].color = 'red'    # => $('blank_slate').style.color = 'red';


1146
1147
1148
1149
# File 'lib/action_view/helpers/prototype_helper.rb', line 1146

def [](attribute)
  append_to_function_chain!(attribute)
  self
end

#[]=(variable, value) ⇒ Object



1151
1152
1153
# File 'lib/action_view/helpers/prototype_helper.rb', line 1151

def []=(variable, value)
  assign(variable, value)
end

#reload(options_for_replace = {}) ⇒ Object



1163
1164
1165
# File 'lib/action_view/helpers/prototype_helper.rb', line 1163

def reload(options_for_replace = {})
  replace(options_for_replace.merge({ :partial => @id.to_s }))
end

#replace(*options_for_render) ⇒ Object



1159
1160
1161
# File 'lib/action_view/helpers/prototype_helper.rb', line 1159

def replace(*options_for_render)
  call 'replace', @generator.send(:render, *options_for_render)
end

#replace_html(*options_for_render) ⇒ Object



1155
1156
1157
# File 'lib/action_view/helpers/prototype_helper.rb', line 1155

def replace_html(*options_for_render)
  call 'update', @generator.send(:render, *options_for_render)
end