开发者

Rails 3 :remote => true does not trigger AJAX requests

I have the following:

<%= link_to "Exhibitions", :action => 'tabExhibitions', :id => @app.id, :remote => true %>

It generates:

<div class="tabbarButton" id="tabbarExhibitions">
    <a href="/apps/3/tabExhibitions?remote=true">Exhibitions</a>
</div>

Which results in a common GET request when clicked.

I am new to Rails but my understanding was that setting :remote => true should have created a <a href="..." data-remote=true> instead of a plain link.

I am using jQuery, the necessary h开发者_C百科eaders and meta tags are in place. I should mention this project was upgraded from Rails 2.3.8

Thanks for all the help.


link_to is putting :remote => true into the url portion of the argument list, and creating a query-string parameter for it (see the parameters in the documentation). Essentially, what you've written is:

<%= link_to "Exhibitions", { :action => 'tabExhibitions', :id => @app.id, :remote => true } %>

You'll want to have a separate Hash for the html_options:

<%= link_to "Exhibitions", { :action => 'tabExhibitions', :id => @app.id }, :remote => true %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜