我使用的是rails 3.0.0.beta
有没有新的语法来编写RJS,下面是一个例子
def remote_create
@photo = Photo.new(params[:photo])
respond_to do |format|
if @photo.save
# add @photo's thumbnail to last import tag
format.js {
render :update do |page|
page.insert_html :bottom, 'polaroids' , :partial => 'polaroid', :locals => {:photo => @photo}
end
}
else
#...
end
end
end发布于 2010-03-15 17:13:45
这里是截屏视频http://railscasts.com/episodes/205-unobtrusive-javascript
2011年4月更新: RJS正在为Rails 3.1提取
prototype--当Rails 3.1问世时,Rails将成为一颗宝石
在3.1版本之前,使用RJS的应用程序在使用Rails master时必须将这一行添加到它们的Gemfile中:
gem 'prototype-rails', :git => 'git://github.com/rails/prototype-rails.git'有关ruby on rails的更多信息可以在this article中找到
发布于 2010-03-14 06:55:18
我不确定rails 3irt rjs的语法有什么变化,但我建议关注railscasts.com -他一直在发布rails 3的所有新特性的视频,如果有任何关于如何渲染/处理js的更新,我相信他会在上面做一集。
https://stackoverflow.com/questions/2439327
复制相似问题