Contenu connexe Similaire à JavaScript on Rails 튜토리얼 (20) JavaScript on Rails 튜토리얼1. Java Script on Rails 제 5 회 루비세미나 발표자료 (2007 년 12 월 1 일 ) 튜토리얼 [email_address] http://thinkr.egloos.com http ://usefulparadigm.com 2. 모든 자바스크립트 마법이 시작되는 한 줄 <%= javascript_include_tag :defaults %> 5. RJS = Ruby generated JavaScript try { $("here").visualEffect("highlight"); } catch (e) {alert('RJS error:' + e.toString()); alert('$(amp;quot;hereamp;quot;).visualEffect(amp;quot;highlightamp;quot;);'); throw e } page[‘here’].visual_effect(…) page.select(‘xxx’).doSomething ... class ThingsController < .. def do ... # process rutines end <%= link_to_remote “Hello,”, :url => do_things_path %> <div id=“ here ”>World!</div> Form Rails RJS Hello, World! Hello, World! 6. Ajax Request Processing <div id=“ userlist ”>...</div> <% remote_form_for :user, :update => ‘ userlist ’, :position => :bottom, :url => users_path do … render :partial => :user, :locals => … <div id=“ userlist ”>...</div> <% remote_form_for :user, :url => users_path do … page.insert_html :bottom, ‘ userlist ’ , :partial => :user, :locals => … 액션 뷰 뷰 Ajax Request RJS Ajax Request 10. WHERE do I put my JS? <%= yield :javascript %> layouts/application.rhtml <% content_for :javascript do %> <%= javascript_include_tag :my_own %> <% end %> controllers/index.rhtml var myObject = function() { ... public/javascripts/my_own.js