I am trying to build a loop of forms in rails that will create (among else) multiple instances of the following two inputs:
<input class="input-small" id="offer_value" min="0" name="offer[value]" step="any" type="number" />
<input class="input-small" id="total" readonly="readonly" value=""/>
The value of the second one should change with a change in the value of the first one according to the following coffeescript:
$ ->
$('#offer_value').change ->
$('#total').val($('#offer_value').val()*2).change();
My problem is that if I give the same id to all (offer_value, total), then the coffeescript hanldes only the first that it finds (giving the same ids sounds wrong anyway).
If I give unique ids (offer_value1, offer_value2,...) then how can I catch them all without writing coffeescripts for all of them?