相关 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
查看:
<iframe name="host_queues", scrolling="yes" width="82%" height="700px", align="right", frameborder="0", rel="stylesheet"></iframe>
<%= link_to host, { :controller => "test_queues", :action => "show_host", :id => id}, {:target => "host_queues"} %>
现在的问题是,它适用于替换 iframe 的内容,但是当我尝试用 class="host_queues"替换 div 中的内容时,它不起作用...仅适用于 iframe ..
任何人都可以指出原因吗? 10倍..
最佳答案
target
仅适用于框架和窗口。您必须使用 Javascript 来替换 div
的内容。
关于javascript - link_to 不替换 div 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21270473/