datatable dropdown toggle not working

Solutions on MaxInterview for datatable dropdown toggle not working by the best coders in the world

showing results for - "datatable dropdown toggle not working"
Daniel
06 May 2020
1$('#payment-notcompleted-table').DataTable().ajax.reload( function() {
2  // initialize dropdown
3  $('.dropdown-toggle').dropdown();
4});
Camila
26 May 2019
1CAUSE
2Pages other than first do not exist in DOM at the time of initialization, that is why your handler never gets called.
3
4SOLUTION
5You need to use event delegation by providing selector as a second argument in on() call, see example below:
6$(document).ready(function(){
7    $('#table_name').DataTable();
8
9    $('#table_name').on('click', '.some-toggle-class', function(){
10        // your code here
11    });   
12});
13