datatables.net-buttons-bs5 - Default.Buttons is undefined
datatables.net-buttons-bs5 - Default.Buttons is undefined
Hi all,
I may just be crazy, but I'm having difficulty setting up datatables using node and bootstrap 5. Following the download on the website it says it should be as simple as pulling down the packages and running:
import DataTable from 'datatables.net-bs5';
import 'datatables.net-buttons-bs5';
However, doing so (without any additional code to instantiate the datatable) gives me the following error in the browser console:
Uncaught TypeError: datatables_net_bs5__WEBPACK_IMPORTED_MODULE_1__.default.Buttons is undefined
However, if I just use import 'datatables.net-buttons-dt';
then datatables works somewhat as expected - missing the BS5 stylings. Has anyone else come across this? Is it a bug? Or is there some other additional setup I need to do to get bootstrap 5 stylings on the buttons.
Thanks,
Answers
I'm not sure what is going wrong without being able to see it I'm afraid. I've just put this little example together using DataTables core and Buttons, both with Bootstrap 5 styling, and it appears to operate as expected.
I've used Vite rather than Webpack, but unless there is a configuration error in your Webpack that shouldn't make a difference.
Allan
Thanks for this Allan, I'll continue investigating tomorrow. Let you know if I come up with anything.