I have a table with multiple checkbox inputs:
<form>
<table id="table">
<tr>
<td><input type="checkbox" value="1" class="someClass"></td>
<td><input type="checkbox" value="1" class="someClass"></td>...
And some jquery that refreshes the table from another file when the box is checked/unchecked:
$(".someClass").on("change", function() {
$('#edit').ajaxSubmit(); //Submitting the form with id "edit"
$("#table").load("tablerefresh");
});
My problem is that when I check/uncheck a box, the table will refresh only once, and it should do it every time I check/uncheck the box, I've looked everywhere and can't seem to find a solution. Any ideas?
This is probably a matter of delegation, since #table
doesn't change, use it as the scope, targeting .someClass
inside:
$("#table").on("change", ".someClass", function() {
$('#edit').ajaxSubmit(); //Submitting the form with id "edit"
$("#table").load("tablerefresh");
});
Note:
You can also use delegate()
:
$("#table").delegate(".someClass", "change", function(){
//Code
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With