诗歌rails之RJS tips

Java代码 
  1. # do_magic.rjs  
  2. page[:reviews].toggle  
  3.   
  4. page[:review_name].value = "this is cool"  
  5.   
  6. page << "if ($('review_name').value == 'foo') ("  
  7. page.alert('hi foo!')  
  8. page << ")"  
  9.   
  10. page.select("#reviews strong").each do |element|  
  11.   element.visual_effect :highlight  
  12. end  

在页面中我们也可以使用link_to_function来直接写rjs: 
Java代码 
  1. <%=  
  2. link_to_function "Show me the Magic!" do |page|  
  3.   page.select("#reviews strong").each do |element|  
  4.     element.visual_effect :highlight  
  5.   end  
  6. end  
  7. %>  
posted @ 2010-06-11 11:11  麦飞  阅读(143)  评论(0编辑  收藏  举报