I have a click event that selects all of the checkboxes within a form. I also have an on change function which gets triggered when each checkbox is clicked individually, but it does not fire if the user selects all of the checkboxes.
I originally only had an on click for the checkboxes, but switched it to an on change event handler, but it still does not receive a change event when I select all of the checkboxes.
The following code sorts each column except for the 'Graph' column, which successfully places a check in each checkbox.
$('th').click(function(){
if(this.innerHTML != 'Graph') {
var table = $(this).parents('table').eq(0)
var rows = table.find('tr:gt(1)').toArray().sort(comparer($(this).index()))
this.asc = !this.asc
if (!this.asc){rows = rows.reverse()}
for (var i = 0; i < rows.length; i++){table.append(rows[i])}
}
else {
let checkBoxes = $('.graph-this');
checkBoxes.prop('checked', !checkBoxes.prop('checked'));
}
});
however,
$(".graph-this").on('change', function(event){
/* this does stuff when I click on each checkbox individually, but not when I click on the 'Graph' th.*/
}
Checks are being placed within the checkboxes, but the change event is not firing. Am I missing something, or is there another event that can be used (apart from change) that is fired on the checkboxes when the 'Graph' th is clicked?
Thanks for the help!
Aucun commentaire:
Enregistrer un commentaire