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:
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
Now, when i want to replace the div content, it doesnt work, it just redirects me to show_host.html.erb
So how can i replace the div using this method ?
I think you are looking for the remote: true
option in your link_to
method.
You may also need to add a
format.js { render layout: false }
to your controller method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.