cannot reinitialize dataTable error

cannot reinitialize dataTable error

tomishtomish Posts: 17Questions: 11Answers: 0

Hi, I have built a dataTable that displays json data through an ajax call. When a user clicks on a cell, the underlying data appears in a modal window (for example, the clickable cell displays '12', the modal window with a new table shows those 12 employees). The user can then click on the dismiss or close button on the modal which makes it disappear. But when they click on another cell (without refreshing the page) they get the 'cannot reinitialize dataTable error.' I understand the best way to handle this error is through the API but I don't know how to do that.

So far, I have this, tied to the modal window 'close' and 'dismiss' button, but it does not work:

   var infoModal = $('#myModal');   

     $('#myModal').on('hidden.bs.modal', function () {
         $('#pc_table').dataTable({
             destroy: true
});

  alert('hidden event fired!');
});

The alert does appear so I know the event is fired.

Thanks!

This discussion has been closed.