Topic: Using Javascript to toggle (show/hide) modal
snirkleshift asked 4 years ago
In vanilla Bootstrap i can use this method to initialize a modal: const myModal = new bootstrap.Modal(document.getElementById('myModal'), options)
and then do things with it like myModal.show()
.
MDB 4.x has $('#myModal').modal('show')
but this gives me the following error message:
Uncaught TypeError: $(...).modal is not a function
What is the MDB 5 way of doing this?
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Open
- User: Free
- Premium support: No
- Technology: MDB Standard
- MDB Version: 3.2.0
- Device: PC
- Browser: All
- OS: Windows 10
- Provided sample code: No
- Provided link: No
Grzegorz Bujański staff commented 4 years ago
Do you mean the MDB jQuery version or MDB 5? In MDB 5 you can use this code to initialize a modal: const
myModal = new mdb.Modal(document.getElementById('myModal'))
. Then you can usemyModal.show()