[英]replace div with rails using link_to
I would like to replace a div content with a content of another html.erb page, now i know its possible with link_to, and it worked for me: 我想用另一个html.erb页面的内容替换div内容,现在我知道可以通过link_to来实现,并且对我有用:
in the view: 在视图中:
link_to host, { :controller => "test_queues", :action => "show_host", :id => id}, {:target => "host_queues"} %>
<iframe name="host_queues", scrolling="yes" width="82%" height="700px", align="right", frameborder="0", rel="stylesheet"></iframe>
In the controller: 在控制器中:
def show_host
queue = testQueue.find(params[:id])
@test_queues = testQueue.where(:host => queue.host)
respond_to do |format|
format.html { render action: "show_host", :layout => nil}
format.json { render json: @test_queue }
end
end
And there is a page called show_host.html.erb 还有一个名为show_host.html.erb的页面
Now, when i want to replace the div content, it doesnt work, it just redirects me to show_host.html.erb 现在,当我要替换div内容时,它不起作用,它只是将我重定向到show_host.html.erb
So how can i replace the div using this method ? 那么,如何使用这种方法替换div?
I think you are looking for the remote: true
option in your link_to
method. 我认为您正在
link_to
方法中寻找remote: true
选项。
You may also need to add a 您可能还需要添加一个
format.js { render layout: false }
to your controller method. 到您的控制器方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.