Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails remote call not working in Firefox

The following link works fine in Chrome and Edge, but doesn't in Firefox and IE. Checking the network graph for both show that the request is not sent. Holding my mouse over the link in Chrome and Edge will show an underline under the text and the destination at the bottom of the page. Firefox and IE do not show these, so it appears that IE and Firefox do not recognize this as a link

<a data-remote="true" rel="nofollow" data-method="post" href="/fetch_data?macaddress=ACB3131B6445&time=hour">Hour</a>

Link is generated with:

<%= link_to "Hour", fetch_data_path(time: "hour", macaddress: @macaddress.to_s), method: :post, :remote => true %>

Edit: Jquery version is the latest, 3.1.

application.js:

//= require jquery3
//= require jquery_ujs
//= require_tree .
like image 606
John Moffitt Avatar asked Jul 02 '16 14:07

John Moffitt


1 Answers

Turns out my laziness was the cause.

I initially made my buttons incorrectly such that they only worked if you clicked on the text of the link rather than the whole button working as a button:

<button class="btn btn-default" type="button">
    <%= link_to "Day", fetch_data_path(time: "day", macaddress: @macaddress.to_s), method: :post, :remote => true %>
</button>

Finally decided that I should fix this and after recreating the link it worked fine in firefox:

<%= link_to fetch_data_path(time: "day", macaddress: @macaddress.to_s), method: :post, :remote => true do %>
    <div class="btn btn-default" type="button">Day</div>
<% end %>
like image 148
John Moffitt Avatar answered Nov 04 '22 23:11

John Moffitt