Topic: Tree view - event listener vs jQuery .on
I would like to ask you, if is possible to catch events of treeview via
jQuery by $('.class').on('activeItem.mdb.treeview')
or only javascript
addEventListener('activeItem.mdb.treeview'..) possible.
I am not sure if I am doing something wrong when jQuery code is not able to catch that event or if it is correct and only javascript addEventListener is correct.
Grzegorz Bujański staff answered 2 years ago
It seems that the problem is not with the plugin itself. In another component, I also couldn't use jQ to listen to the event. We will check it and try to fix it. For now, use addEventListener
as a workaround.
meesha81 pro premium priority commented 2 years ago
Yes, no other function can be catch by jQ, but i wanna provide one particular case. We use addEventListener but with more and more time spent with MDB I found out that it can be "problem".
Grzegorz Bujański staff commented 2 years ago
Hi, We've done some tests and checked what's going on. Turns out the problem only occurs if you import the MDB first and then the jQ. Our components initialize automatically after loading. We could initialize them on page load. This would solve the import order issue. But some of the components add classes and styles or new elements to the page. This behavior has a negative impact on SEO. Therefore, we decided not to implement this solution. If in your case you first imported jQuery and then MDB and this problem occurred, let me know. We will check what is causing the issue in your case
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 6.1.0
- Device: PC
- Browser: CHROME
- OS: WIN11
- Provided sample code: No
- Provided link: No