Topic: Problem with components initialization on V7.2.0 and UMD format
Expected behavior
components should initialize
Actual behavior
after migration from v6 to v7 in UMD format, components don't initialize although I added the data-mdb-{component-name}-init property.
For example, using toats, I get an error in the browser console : TypeError: can't access property "show", basicInstanceSuccess is null (see the code in the sandbox link below)
In my site, if I replace mdb.Toast.getInstance(eljToastSuccess) by mdb.Toast.getOrCreateInstance(eljToastSuccess), it works OK. That means the toast component hasn't been initialized, but I don't know why. I have the same error for all compnents that need to be initialized.
Resources (screenshots, code snippets etc.)
When I copy my code to the MDB sansbox, it works https://mdbootstrap.com/snippets/standard/efilippi/6024386
When the code is in my site, it doesn't work, although I included :
<!-- MDB ESSENTIAL -->
<script type="text/javascript" src="assets/templates/ELJ_4/js/mdb.umd.min.js"></script>
<!-- MDB PLUGINS -->
<script type="text/javascript" src="assets/templates/ELJ_4/plugins/js/all.min.js"></script>
at the end of the page body.
See a page source example : https://www.dropbox.com/scl/fi/iisyqy58wkcorc9gjx7up/code_toast.html?rlkey=dq9juo1mh2pvc9ldmzbg7n2mn&dl=0
Can you help me to find what I've done wrong ?
Thank you. Eric
Kamila Pieńkowska staff answered 8 months ago
Do the components that does not work for you are present on the page on the page load? Do you get any errors?
Toasts in the code you provided does not have initialization attribute.
efilippi pro premium priority commented 8 months ago
You're right, I found a problem il my ftp transfer. Now with the correct files, it works perfectly !
Many thanks.
Eric
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 7.2.0
- Device: LapTop
- Browser: Firefox, chrome
- OS: Debian
- Provided sample code: No
- Provided link: Yes