5.3. RJS (Ruby
JavaScript)
This example:
update_page do |page|
page.insert_html :bottom, 'list', "<li>#{@item.name}</li>"
page.visual_effect :highlight, 'list'
page.hide 'status-indicator', 'cancel-link'
end
generates the following JavaScript:
new Insertion.Bottom("list", "<li>Some item</li>");
new Effect.Highlight("list");
["status-indicator", "cancel-link"].each(Element.hide);
Learn more:
-
api.rubyonrails.com/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html
-
http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates
-
http://scottraymond.net/articles/2005/12/01/real-world-rails-rjs-templates
-
http://www.rubynoob.com/articles/2006/05/13/simple-rails-rjs-tutorial
 |