我有以下内容:
<%= link_to "Exhibitions", :action => 'tabExhibitions', :id => @app.id, :remote => true %>
它生成:
<div class="tabbarButton" id="tabbarExhibitions">
<a href="/apps/3/tabExhibitions?remote=true">Exhibitions</a>
</div>
单击时会产生常见的 GET 请求。
我是 Rails 新手,但我的理解是设置 :remote => true
应该创建一个 <a href="..." data-remote=true>
而不是简单的链接。
我正在使用 jQuery,必要的 header 和元标记已就位。我应该提到这个项目是从 Rails 2.3.8 升级的
感谢您的帮助。
最佳答案
link_to
将 :remote => true
放入参数列表的 url
部分,并为其创建一个查询字符串参数(参见参数 in the documentation )。本质上,您所写的是:
<%= link_to "Exhibitions", { :action => 'tabExhibitions', :id => @app.id, :remote => true } %>
您需要为 html_options
有一个单独的哈希:
<%= link_to "Exhibitions", { :action => 'tabExhibitions', :id => @app.id }, :remote => true %>
关于ajax - 轨道 3 :remote => true does not trigger AJAX requests,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5773544/