<%= javascript_tag do %> $(document).ready(function() { var table = $('#invoices-table').DataTable({ "dom": "t", "paging": false, "ajax": "<%= account_invoices_path :format => :json %>", "processing": true, "serverSide": true, "search": {"search": $('#account_id').val()}, "columnDefs": [ { "targets": [ 4 ], "orderable": false } ], createdRow: function(row, data, dataIndex) { $('td', row).eq(4).html('') }, drawCallback: function() { $('input').change(function() { var table = $('#invoices-table').DataTable(); var total = 0; table.rows().every(function (rowIdx, tableLoop, rowLoop) { var d = this.data(); total += parseFloat($('#payment_amount_' + rowIdx).val(), 10); }); if (total != parseFloat($('#payment_amount').val(), 10)) { $('#deposit_amount_mismatch').css('visibility', 'visible'); $('#submit-btn').prop('disabled', true); } else { $('#deposit_amount_mismatch').css('visibility', 'hidden'); $('#submit-btn').prop('disabled', false); } }); } }); }); <% end %>