Class: Mjs::JavaScriptElementProxy
- Inherits:
-
JavaScriptProxy
- Object
- JavaScriptProxy
- Mjs::JavaScriptElementProxy
- Defined in:
- lib/mjs/java_script_context.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.
428 429 430 431 |
# File 'lib/mjs/java_script_context.rb', line 428 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 Mjs::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';
439 440 441 442 |
# File 'lib/mjs/java_script_context.rb', line 439 def [](attribute) append_to_function_chain!(attribute) self end |
#[]=(variable, value) ⇒ Object
444 445 446 |
# File 'lib/mjs/java_script_context.rb', line 444 def []=(variable, value) assign(variable, value) end |
#reload(options_for_replace = {}) ⇒ Object
456 457 458 |
# File 'lib/mjs/java_script_context.rb', line 456 def reload( = {}) replace(.merge({ :partial => @id.to_s })) end |
#replace(*options_for_render) ⇒ Object
452 453 454 |
# File 'lib/mjs/java_script_context.rb', line 452 def replace(*) call 'replace', @generator.send(:render, *) end |
#replace_html(*options_for_render) ⇒ Object
448 449 450 |
# File 'lib/mjs/java_script_context.rb', line 448 def replace_html(*) call 'update', @generator.send(:render, *) end |