I've created a datatable with a collection button that will hide and show column groups. When one of the hide/show buttons is clicked I want to call an event listener. My eventlistener will not fire -- I have no idea what I'm doing wrong and have tried so many iterations to fix it that my head is in code fog right now. Can somebody spot what it is that I'm doing wrong?
var counter = 1;
var dtab = $('#tblCohort').DataTable({
paging: false,
dom: 'Brt',
buttons: [{
extend: 'collection',
text: 'Section Visibility',
buttons: []
},
'copy', 'excel', 'pdf'
]
});
dtab.button().add('0-0', {
extend: 'colvisGroup',
text: 'Hide Section 1',
className: 'hidesec1',
hide: '.sec1'
})
dtab.button().add('0-1', {
extend: 'colvisGroup',
text: 'Show Section 1',
className: 'showsec1',
show: '.sec1'
})
dtab.button().add('0-2', {
extend: 'colvisGroup',
text: 'Hide Section 2',
className: 'hidesec2',
hide: '.sec2'
})
dtab.button().add('0-3', {
extend: 'colvisGroup',
text: 'Show Section 2',
className: 'showsec2',
show: '.sec2'
})
$('.hidesec1').click(function() {
alert('hide sec 1');
})