Topic: initMDB is not a function
Sebastian Sauer asked 10 months ago
Expected behavior According to definition this ES Import should work: import { Input, initMDB } from "mdb-ui-kit"; initMDB({ Input });
I am using Typescript with ES2022 module.
The input fields should be initialized Uncaught TypeError: mdb_ui_kit__WEBPACK_IMPORTED_MODULE_8__.initMDB is not a function
Resources (screenshots, code snippets etc.)
Sebastian Sauer answered 10 months ago
Before you investigate further, i figuered out, that this issue has been caused by a npm related error, where it ignored the version and installed an old one.
After fixing up NPM and updating it works :)
MDBootstrap staff pro premium priority answered 10 months ago
Sebastian Sauer answered 10 months ago
I have installed the MDB UI Kit via NPM. I am also using Webpack and Typescript. Main Import is done in the index.ts file:
import * as mdb from "mdb-ui-kit"; or `import "mdb-ui-kit/js/mdb.min.js";`
Then I try to import it in another ts file
import { Input, initMDB } from "mdb-ui-kit";
initMDB({ Input });
When the function tries to execute, the above mentioned error occurs. On the other hand importing Modals does work, so i don't know if i caused the issue.
import { Modal } from "mdb-ui-kit";
let modalExec = document.getElementById("anyHtmlModal");
mdbModal = new Modal(modalExec); //This does work within my application :)
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: No
- Technology: MDB Standard
- MDB Version: MDB5 7.1.0
- Device: Laptop
- Browser: Edge
- OS: Windows 11
- Provided sample code: No
- Provided link: No