mercredi 16 juin 2021

Check/Uncheck all checkbox on different page

I'm trying to get, by checking or unchecking one checkbox, in order to check/uncheck all checkboxes called by data-ajax-source.

actually i can check/uncheck all checkboxes on the current page but my list is based on several pages.

I do have make a lot research but nothing work for me.

My th :

<table id="someid" class="data display datatable" data-sort="[[1, 'asc']]" data-ajax-source="">
<thead>
    <tr>
        <th class="no_sort"><input type="checkbox" name="check_all" value="check_all" checked /></th>
        <th width="15%">firstname</th>
        <th width="15%">lastname</th>
        <th width="55%">Email(s)</th>
        <th class="no_sort" width="10%">Blacklist ?</th>
    </tr>
</thead>

data :

<input type="checkbox" name="element-ids[]" value="" checked />

<div></div>

<div></div>

<div>
    
</div>

JQuery code :

$('form table input[name="check_all"]').on('change', function() {
    $(this).closest('table').find('input[type="checkbox"]:not(:disabled)').prop('checked', $(this).prop('checked'));
});

In the html, i think each page is equal to a different table element, that is why i can not select/deselect one checkbox to check/uncheck all checkboxes on all pages. Because when i change page, the "main" checkbox is always checked by default as i have set.

so what can i change to reach my goal ?

Thanks a lot in advance.




Aucun commentaire:

Enregistrer un commentaire