Bug dataTable.buttons.js
Bug dataTable.buttons.js
ATIMIC
Posts: 4Questions: 1Answers: 0
I've noticed something when the destroy function is called (my comment in the code) :
/**
* Destroy the instance, cleaning up event handlers and removing DOM
* elements
* @return {Buttons} Self for chaining
*/
destroy: function ()
{
// Key event listener
$('body').off( 'keyup.'+this.s.namespace );
// Individual button destroy (so they can remove their own events if
// needed
var buttons = this.s.buttons;
var i, ien;
for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
// HERE
// if you have 2 buttons, the first one is removed correctly, i = 0, still one button in buttons
// when it's time to remove the second one, i = 1 but you only have one button in buttons at index 0
// so we get an error 'cannot read property node of undefined'
this.remove( buttons[i].node );
}
// Container
this.dom.container.remove();
// Remove from the settings object collection
var buttonInsts = this.s.dt.settings()[0];
for ( i=0, ien=buttonInsts.length ; i<ien ; i++ ) {
if ( buttonInsts.inst === this ) {
buttonInsts.splice( i, 1 );
break;
}
}
return this;
},
I'm not sure if it's the right place to post that kind of message. If it's not a bug , i think i trying to do something wrong.
Thx
This discussion has been closed.
Replies
Are you using Buttons 1.2.0 by any chance? I think this issue has already been resolved with 1.2.1? If not that, then can you please link to a test case showing the issue so I can help to resolve it.
On this page I can run
$('#example').DataTable().destroy()
and it works as expected.Allan
Yes, i am... thank you for pointing that out, I will update my version !
I'll be more careful next time with version number before posting useless thing