cannot destroy table when using init method on button instances
cannot destroy table when using init method on button instances
Link to test case:
https://live.datatables.net/lotojaya/1/edit
Debugger code (debug.datatables.net):
ejesuy
Error messages shown:
Uncaught TypeError: Cannot read properties of undefined (reading 'split')
at U.<anonymous> (datatables.min.js:16:69323)
at U.off (datatables.min.js:16:47220)
at U.destroy (datatables.min.js:43:13470)
at _.remove (datatables.min.js:26:3846)
at _.destroy (datatables.min.js:26:2745)
at HTMLTableElement.<anonymous> (datatables.min.js:26:4414)
at HTMLTableElement.dispatch (jquery-1.11.3.min.js:4:8549)
at r.handle (jquery-1.11.3.min.js:4:5252)
at Object.trigger (jquery-1.11.3.min.js:4:7650)
at HTMLTableElement.<anonymous> (jquery-1.11.3.min.js:4:15517)
Description of problem:
I want to be able to destroy() a Datatable with buttons with custom init methods to be able to toggle the buttons based on certain permissions when (de)selecting rows.
Destroying is not an issue when init is not used or only set on one button.
Once more than one buttons uses a custom init method I get the above error.
Answers
That is indicative of another issue - it is just that this is the easily visible part.
The real problem is that you are replacing the
selected
button'sinit
function with your own, and not setting it up the same way. That can be done, but thedestroy
method is expected that the originalinit
was called. It isn't therefore they are out of sync.The easiest solution is simply to call the original init function:
https://live.datatables.net/lotojaya/2/edit
Note that I have removed it from the
create
button since that doesn't extend fromselected
.Allan
Understood. I would not have thought of that. Thanks