mercredi 10 juin 2020

Javascript - On click update on change

I'm currently updating a table based on the checkbox a user clicks with on.change. The thing is I'm trying to add a couple of buttons that will mass check some checkboxes with on.click but when I do that the table will not get updated.

I'm using the following code to update the table while a checkbox is checked/unchecked:

$('.options').on( 'change', function () {
    var i =$(this).attr('data-column');
    var v = $('input:checkbox[name="checkstage"]:checked').map(function() {
     return this.value;
   }).get().join('|');
    dataTable.columns(i).search(v).draw();
} );

And this code to mass check/uncheck boxes:

$(document).on('click', '.selectAllCountries', function(e) {
  var $checks = $('.country');
  $checks.prop('checked', !$checks.is(':checked'))

e.stopPropagation();
}); 

It does work and checks all countries but the table is not being updated.




Aucun commentaire:

Enregistrer un commentaire