I'm trying to make a site (just knowledge purpose) that updates every 15 seconds the price of CryptoCoins
To do that i made a setInterval loop and inside it, considering i have 4 coins, made a for iteration to get every element updated.
value_form = document.querySelectorAll("#value-form");
const interval = setInterval(function() {
for (var i = 0; i < value_form.length; i++){
console.log(i)
Rails.fire(value_form[i], 'submit')
// Rails.handleRemote.call(value_form[i]) - Other method i tried but didnt worked as well
}
}, 15000);
But the problem is, after the first time it completes, the Rails.Fire stop tringerring, but the console.log(i) keep working normally...
Can anyone explain why this happens?
PS. This is the element that make the value of the coin
<td id="coin-<%= coin.id %>"><%= render "coin_value", coin: coin %>
<%= form_tag(coins_path, method: :get , id: "value-form", remote: true) do %>
<%= hidden_field_tag "acronym", "#{coin.acronym}"%>
<% end %>
</td>