0

I found out that my javascript code would not work when certain links where clicked.

When i set a breakpoint, the following js was not triggered after certain links

$(document).on('turbolinks:load', ready);

This is the link where js works

<%= link_to companies_path, method: :get, id: "Companies" do %>

This is the link where js does not work

<%= link_to "New Campaign", new_campaign_path, method: :get %>
4

1 回答 1

0

带有该属性的链接method: :getdata-method="get"在他的 html 中有一个

<a id="Companies" data-method="get" href="/companies">

而另一个则没有这种数据方法。

<a class="btn btn-success btn-fill" data-method="get" href="/campaigns/new">New Campaign</a>

我通过使用以下语法显式声明数据方法解决了这个问题。

<%= link_to "New Campaign", new_campaign_path, method: :get %>

我没有在 StackOverflow 上找到任何解释这一点的讨论,但如果你找到它们,请附上链接。

问题解决了

谢谢最好的问候法布里齐奥

于 2017-05-02T14:52:28.553 回答