渲染不同的.js文件使用Rails阿贾克斯 [英] Render different .js file with Rails Ajax
本文介绍了渲染不同的.js文件使用Rails阿贾克斯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你如何呈现一个不同的 .js.erb
文件,而使用Ajax?
How do you render a different .js.erb
file while using Ajax?
例如:
<% form_tag user_path, :method => :get, :remote => true do %>
这经过了 UserController的#秀
然后呈现用户/ show.js.erb
。我如何让它通过了 UserController的#秀
然后渲染用户/ hello.js.erb
?
This goes through the UserController#show
and then renders users/show.js.erb
. How do I make it go through the UserController#show
and then render users/hello.js.erb
?
推荐答案
在 users_controller.rb
def show
@user = User.find(params[:id])
respond_to do |format|
format.js { render 'hello.js.erb' }
end
end
这篇关于渲染不同的.js文件使用Rails阿贾克斯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文