Topic: Cannot initialize Select by API when module is loaded individually
root-nine priority asked 8 months ago
Expected behavior In order to reduce the amount of loaded resources I´m only loading the following scripts:
The select is working correctly when it is initialized automatically on page load. I´m also loading HTML via AJAX and then I need to initialize the selects manually by API. Sample:
const mySelect = new mdb.Select(document.getElementById('mySelect'), options)
Is it possible to use a reduced set of components in this way?
The following error is shown in the browser console:
mdb.Select is not a constructor
Resources (screenshots, code snippets etc.)
When I load the full mdb.min.js (PRO version) I´m able to initialize the select via API. When loading just the free mdb.min.js and the module select.min.js I can see that the mdb-object is missing the "Select" class. Only the components of the free version can be accessed.
If you use something as a module, it won't be available in
mdb object. You should call it just by its name. In this case try using
Select instead of
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
- User: Priority
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 3.11.0
- Device: PC
- Browser: Firefox
- OS: Windows 10
- Provided sample code: No
- Provided link: No