Section 5.3. RJS (Ruby JavaScript)


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:

  • http://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



Ruby on Rails[c] Up and Running
Ruby on Rails[c] Up and Running
ISBN: B003D3OGCY
EAN: N/A
Year: 2006
Pages: 94

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net