如何返回js.html.erb文件中的index.html.erb [英] How to return a the index.html.erb in the js.html.erb file
本文介绍了如何返回js.html.erb文件中的index.html.erb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个这样的控制器:
I have a controller like so:
def index
respond_to do |format|
format.html {}
format.js {render :layout => false}
end
end
index.html.erb
hello i"m index.html.erb
index.js.erb
<%= render :template => "dashboard/index" %>
我想要做的是让 index.html 或 index.js 返回相同的内容.但是如果不使 index.html.erb 成为部分(_index.html.erb),我就无法做到这一点,但是当用户进行无法正常工作的 html 调用时.
What I want to do is have index.html or index.js return the same thing. But I can't see to do that without making index.html.erb a partial (_index.html.erb) but then when a user makes an html call that won't work.
如何让 index.js.erb 呈现 index.html.erb?然后我会用 jQuery 逃脱.谢谢
How can I get the index.js.erb to render index.html.erb? which I would then escape with jQuery. Thanks
推荐答案
尝试:
<%= raw render(:template => "dashboard/index").to_json %>
这篇关于如何返回js.html.erb文件中的index.html.erb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文