Topic: AddEventListener for dropdown not working
Expected behavior console message is logged for the following code
const myDropdown = document.getElementById('myDropdown')
myDropdown.addEventListener('show.mdb.dropdown', () => {
console.log("event fired");
})
Actual behavior nothing happens
Resources (screenshots, code snippets etc.) using the referenced code on https://mdbootstrap.com/docs/standard/components/dropdowns/#docsTabsAPI
const myDropdown = document.getElementById('myDropdown')
myDropdown.addEventListener('show.mdb.dropdown', () => {
// do something...
})
I am adding this to my page and nothing is happening, not even an error
In addition, the "Open in MDB Editor" has console errors and doesn't work.
Grzegorz Bujański staff answered 4 years ago
Here is a working example: https://mdbootstrap.com/snippets/standard/grzegorz-bujanski/2882053
joannarom commented 4 years ago
Hi Grzegorz,
The example provided, does not have any console errors, but it also does not fire off any console logging when clicking on the drop down. So, unfortunately it does not solve my problem.
Grzegorz Bujański staff commented 4 years ago
Can you check again? I see that after opening the dropdown, console.log ("event fired")
is called and I can see this text in the browser console.
maybe you didn't notice him? I also added an alert.
joannarom commented 4 years ago
Hi,
Yes you are correct. I currently am having a really strange browser issue. A lot of the mdb5 components do not work properly on one computer (desktop), but on the other computer they work fine (laptop). Browser versions are all the same.
Unrelated to the above issue, have you seen this happen before?
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Resolved
- User: Free
- Premium support: No
- Technology: MDB Standard
- MDB Version: 3.2.0
- Device: desktop
- Browser: Chrome
- OS: windows
- Provided sample code: No
- Provided link: Yes