Module: Apotomo::JavascriptMethods
- Included in:
- Widget
- Defined in:
- lib/apotomo/widget/javascript_methods.rb
Instance Method Summary collapse
-
#escape_js(script) ⇒ Object
Returns the escaped script.
-
#replace(*args) ⇒ Object
Wraps the rendered content in a replace statement targeted at your
Apotomo.js_framework
setting. -
#update(*args) ⇒ Object
Same as replace except that the content is wrapped in an update statement.
Instance Method Details
#escape_js(script) ⇒ Object
Returns the escaped script.
4 5 6 |
# File 'lib/apotomo/widget/javascript_methods.rb', line 4 def escape_js(script) Apotomo.js_generator.escape(script) end |
#replace(*args) ⇒ Object
Wraps the rendered content in a replace statement targeted at your Apotomo.js_framework
setting. Use :selector
to change the selector.
Example:
Assuming you set
Apotomo.js_framework = :jquery
and call replace in a state
replace :view => :squeak, :selector => "div#mouse"
#=> "$(\"div#mouse\").replaceWith(\"<div id=\\\"mum\\\">squeak!<\\/div>\")"
20 21 22 |
# File 'lib/apotomo/widget/javascript_methods.rb', line 20 def replace(*args) wrap_in_javascript_for(:replace, *args) end |
#update(*args) ⇒ Object
Same as replace except that the content is wrapped in an update statement.
Example for :jquery
:
update :view => :squeak
#=> "$(\"mum\").html(\"<div id=\\\"mum\\\">squeak!<\\/div>\")"
30 31 32 |
# File 'lib/apotomo/widget/javascript_methods.rb', line 30 def update(*args) wrap_in_javascript_for(:update, *args) end |