Rails 3和RJS [英] Rails 3 and RJS
本文介绍了Rails 3和RJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用rails 3.0.0.beta
I use the rails 3.0.0.beta
有没有新的语法可以编写RJS,这是一个示例
Is there any new syntax to write RJS, here is an example
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
推荐答案
以下是截屏视频 http://railscasts.com/episodes/205-unobtrusive-javascript
2011年4月更新:正在为Rails 3.1提取RJS
UPDATE April 2011: RJS is being extracted for Rails 3.1
Rails 3.1推出后,prototype-rails将会成为一颗宝石
prototype-rails is going to be a gem when Rails 3.1 is out
使用RJS的应用程序必须在3.1发行版之前对Rails master进行操作时将此行添加到其Gemfile中:
Applications using RJS have to add this line to their Gemfile while working against Rails master before the 3.1 release:
gem 'prototype-rails', :git => 'git://github.com/rails/prototype-rails.git'
这篇关于Rails 3和RJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文