Topic: Individual modules with hyphens in the file name fail to load
scottwilliams priority asked 2 years ago
According to the optimization page when modules are loaded individually they are outside the mdb global. Got it. No problem. Then it says that individually loaded modules will use the same variable name as its file name. Works as expected... until you have a module with hyphens in the file name! How do I call the function of a module named "date-time-picker.min.js"?
Thanks
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Opened
Specification of the issue
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 3.10.1
- Device: Macbook Pro
- Browser: Chrome
- OS: MacOS 12.1
- Provided sample code: No
- Provided link: No
Dawid Wajszczuk staff commented 2 years ago
Does using
datetimepicker
not work? If not you can build your own version of UI Kit (the last section at optimization page https://mdbootstrap.com/docs/standard/getting-started/optimization/#section-custom-version-of-mdb-ui-kit). Then you will have the mdb global available to you with only those modules that you have chosen to import.scottwilliams priority commented 2 years ago
I get the following error in the console: Uncaught ReferenceError: "datetimepicker is not defined".
My JS looks as follows: const pickerTimeOptions = document.querySelector('#datetimepickerInline'); new datetimepicker(pickerTimeOptions, { timepicker: { format24: true }, });
Everything works until after I select a time and hit OK. Then it hangs.
scottwilliams priority commented 2 years ago
Had to abandon loading modules individually as there were too many problems with module functionality when loaded outside the "mdb" global space.
Dawid Wajszczuk staff commented 2 years ago
Datetimepicker module should be available under
window['date-time-picker']
. But it will probably require also timepicker, datepciker modules (or just CSS modules).