I am trying to prevent user to move first element of dragulaService
, the code works first time without any errors, but when I leave this page and then open it again, I'm getting error.
The code that is causing the error:
constructor(public service:SmartTablesService, private dragulaService:DragulaService) {
dragulaService.setOptions('nested-bag', {
revertOnSpill: true,
moves: function (el:any, container:any, handle:any):any {
if (handle.className === 'sorting-table-title') {
return false;
} else {
return true;
}
}
});
The error is:
error_handler.js:48 EXCEPTION: Uncaught (in promise): Error: Error in ./SortTableComponent class SortTableComponent_Host - inline template:0:0 caused by: Bag named: "nested-bag" already exists. Error: Bag named: "nested-bag" already exists. at DragulaService.add (http://platform.local:8080/3.chunk.js:1070:19) at DragulaService.setOptions (http://platform.local:8080/3.chunk.js:1099:24) at new SortTableComponent (http://platform.local:8080/3.chunk.js:1311:24)
You need to destroy nested-bag
in onDestroy
lifecycle of your component manually because it's not done automatically:
ngOnDestroy() {
this.dragulaService.destroy('nested-bag');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With