Class: ActionView::Helpers::JavaScriptElementProxy
- Inherits:
-
JavaScriptProxy
- Object
- ActiveSupport::BasicObject
- JavaScriptProxy
- ActionView::Helpers::JavaScriptElementProxy
- Defined in:
- lib/action_view/helpers/prototype_helper.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#[](attribute) ⇒ Object
Allows access of element attributes through
attribute
. - #[]=(variable, value) ⇒ Object
-
#initialize(generator, id) ⇒ JavaScriptElementProxy
constructor
A new instance of JavaScriptElementProxy.
- #reload(options_for_replace = {}) ⇒ Object
- #replace(*options_for_render) ⇒ Object
- #replace_html(*options_for_render) ⇒ Object
Constructor Details
#initialize(generator, id) ⇒ JavaScriptElementProxy
Returns a new instance of JavaScriptElementProxy.
1140 1141 1142 1143 |
# File 'lib/action_view/helpers/prototype_helper.rb', line 1140 def initialize(generator, id) @id = id super(generator, "$(#{::ActiveSupport::JSON.encode(id)})") 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';
1151 1152 1153 1154 |
# File 'lib/action_view/helpers/prototype_helper.rb', line 1151 def [](attribute) append_to_function_chain!(attribute) self end |
#[]=(variable, value) ⇒ Object
1156 1157 1158 |
# File 'lib/action_view/helpers/prototype_helper.rb', line 1156 def []=(variable, value) assign(variable, value) end |
#reload(options_for_replace = {}) ⇒ Object
1168 1169 1170 |
# File 'lib/action_view/helpers/prototype_helper.rb', line 1168 def reload( = {}) replace(.merge({ :partial => @id.to_s })) end |
#replace(*options_for_render) ⇒ Object
1164 1165 1166 |
# File 'lib/action_view/helpers/prototype_helper.rb', line 1164 def replace(*) call 'replace', @generator.send(:render, *) end |
#replace_html(*options_for_render) ⇒ Object
1160 1161 1162 |
# File 'lib/action_view/helpers/prototype_helper.rb', line 1160 def replace_html(*) call 'update', @generator.send(:render, *) end |