My jQuery works great on the initial load of my Bootstrap Table. However, after paging forward or back it stops working even though the elements haven't changed and haven't been removed. Why?
Here is my jQuery
$(document).ready(function() {
$(function(){
$(".fresh-credit-update-button").click(function(){
console.log("clicking");
var customerId = $(this).parent().siblings(".fresh-credit-update-data").attr('id');
var customerCreditUpdateField = $(this).parent().siblings(".fresh-credit-update-data");
var customerCreditUpdate = customerCreditUpdateField.html('value').val();
$.ajax({
url: "/customers/update",
data: {id: customerId, credit_amount: customerCreditUpdate},
type: "POST",
dataType: "json",
complete: function(data) {
console.log(data.responseJSON.credit_amount);
customerCreditUpdateField.val("$" + data.responseJSON.credit_amount);
},
}); //ajax
}); // button click
}); // 2nd function
}); // document ready
And then here is the table its watching
<tbody>
<% @all_customers.each do |individual| %>
<tr>
<td></td>
<td><%= "#{individual.first_name} #{individual.last_name}" %></td>
<td>
<div class="input-group input-group-med">
<input type="text" id="<%= individual.id %>" class="fresh-credit-update-data form-control small-field" value=<%= number_to_currency(individual.credit_amount) %>>
<span class="input-group-btn-med">
<button class="btn btn-med fresh-credit-update-button" type="button">Update</button>
</span>
</div><!-- /input-group -->
</td>
<td><%= number_to_currency(individual.pending_credit_amount) %></td>
<td><%= individual.email %></td>
<td><%= individual.accepts_marketing %></td>
<td><%= individual.customer_status %></td>
<td><%= individual.tags %></td>
</tr>
<% end %>
</tbody>