lib/apotomo/widget/javascript_methods.rb in apotomo-1.1.0 vs lib/apotomo/widget/javascript_methods.rb in apotomo-1.1.1
- old
+ new
@@ -3,31 +3,35 @@
# Returns the escaped script.
def escape_js(script)
Apotomo.js_generator.escape(script)
end
- # Wraps the rendered content in a replace statement targeted at your +Apotomo.js_framework+ setting.
- # Use +:selector+ to change the selector.
+ # Wraps the rendered content in a replace statement according to your +Apotomo.js_framework+ setting.
+ # Received the same options as #render plus an optional +selector+ to change the selector.
#
- # Example:
+ # Example (with <tt>Apotomo.js_framework = :jquery</tt>):
#
- # Assuming you set
- # Apotomo.js_framework = :jquery
+ # def hungry
+ # replace
#
- # and call replace in a state
+ # will render the current state's view and wrap it like
#
- # replace :view => :squeak, :selector => "div#mouse"
- # #=> "$(\"div#mouse\").replaceWith(\"<div id=\\\"mum\\\">squeak!<\\/div>\")"
+ # "$(\"#mouse\").replaceWith(\"<div id=\\\"mouse\\\">hungry!<\\/div>\")"
+ #
+ # You may pass a selector and pass options to render here, as well.
+ #
+ # replace "#jerry h1", :view => :squeak
+ # #=> "$(\"#jerry h1\").replaceWith(\"<div id=\\\"mouse\\\">squeak!<\\/div>\")"
def replace(*args)
wrap_in_javascript_for(:replace, *args)
end
- # Same as replace except that the content is wrapped in an update statement.
+ # 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>\")"
+ # update :view => :peek
+ # #=> "$(\"#mouse\").html(\"looking...")"
def update(*args)
wrap_in_javascript_for(:update, *args)
end
private