mpsbhat
mpsbhat

Reputation: 2773

Checked counter is not working in jquery data table pagination

I have a jquery datatable in this fiddle with check boxes and dropdown selector. I am counting the checked checkboxes as,

function updateCount () {

            count = $("input[name='check']:checked").length;
            agebelow = $(".AgeSelect option:selected[name='below']").length;
            ageabove = $(".AgeSelect option:selected[name='above']").length;

          $("#count").text(count);
          if (count > 0) {         
          $("#status").toggle(count > 0);
          }

        $('#count2').text(agebelow);
         if ( agebelow > 0 ) {
          $("#status2").toggle(agebelow > 0);
          }

           $('#count1').text(ageabove);
         if ( ageabove > 0 ) {
          $("#status1").toggle(ageabove > 0);
          }

        };

The counter working fine in first page of data table. But in other pages the counter not updating when i checked a checkbox. The same is applied to the dropdown also. So how can I fix this issue?

Upvotes: 1

Views: 1329

Answers (1)

vvahans
vvahans

Reputation: 1857

You need to use fnGetNodes() method of object returned when you initializing dataTable on your table.

Here is a fix using that approach.

Upvotes: 6

Related Questions