jquery select2 not working properly with datatable page limit change

jquery select2 not working properly with datatable page limit change

mittulatttechnobravemittulatttechnobrave Posts: 1Questions: 1Answers: 0

I am using jQuery's Select2 library as a replacement for select boxes with jQuery's Table plugin called as DataTables.

I have integrated both plugins together and its working fine except for one issue.

I have a Dropdown through which I can change the limit to show number of records per page.

Say for example I have 15 records and default I am showing maximum 10 records per page. When I change it from 10 to 25 then my Page drop-down does not update from value 2 to 1.

Here below are the screenshots whats happening at the moment.

enter image description here

enter image description here

As you can see in my second screenshot, even if I have 25 records to see, the Page option still saying Page 1 of 2.

This feature works well if I do not integrate select2 in my pagination class using jQuery.

Below is the code What I have done so far to initialize select2 in my DataTables.

"fnDrawCallback": function (oSettings) {
            $("#datatable_status").select2();
            $(".dataTables_length select").select2();
            $(".dataTables_paginate select").select2();     

        }

And if I comment the line $(".dataTables_paginate select").select2(); then it works well but select2 style wont be there anymore for my Pagination dropdown.

enter image description here

Can someone guide me what I am doing wrong here ? What should I do to get valid count in my Pagination dropdown ?

Thanks

This discussion has been closed.