Skip to content

fix: use DOMContentLoaded #237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2025
Merged

fix: use DOMContentLoaded #237

merged 1 commit into from
Apr 28, 2025

Conversation

Seb33300
Copy link
Contributor

@Seb33300 Seb33300 commented Apr 24, 2025

In our project, we sometimes faces the following javascript error:

Uncaught Cannot extend unknown button type: reset

This is because buttons are defined inside the DOMContentLoaded event:
https://github.com/yajra/laravel-datatables-vite/blob/3d1d1364e43f9bea547dae9a19236bcfd38d32bd/js/buttons/reset.js#L9

That error does not happens every time, I cannot explain why, but I am not able to reproduce it if I use DOMContentLoaded instead of $(function(){ }.
For some reason, even if it is supposed to be equivalent to DOMContentLoaded, $(function(){ } seems to be faster than DOMContentLoaded in some cases.

So let's use DOMContentLoaded here to be consistent with buttons.

@yajra yajra merged commit 2c07222 into yajra:master Apr 28, 2025
6 of 7 checks passed
@yajra
Copy link
Owner

yajra commented Apr 28, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants