Topic: Do you consider adding the functionality of event rebinding?
ankio free asked 1 year ago
I'm using pjax to load pages, but I found a problem that the input fields lose their original style after being loaded by pjax. I guess it may be because the elements are not associated with the relevant events after pjax loading.I tried to reload mdb.min.js after pjax loading, but I found that many events were bound repeatedly.So I hijacked Element.prototype.addEventListener and tried to remove these event listeners after pjax loading, but I couldn't remove these events. I think the best solution is for the official library to provide a method for reloading or rebinding events on updated elements after pjax loading.
Grzegorz Bujański staff answered 1 year ago
Our components work in such a way that they are initialized when the MDB file is loaded. So if you add some content dynamically, it won't be initialized automatically. As you've noticed with inputs, this causes the input styles are not set. But you can do component initialization yourself. In our documentation in the API tab, you will find how to execute init via JS. If you do this, the appropriate styles will be set and the necessary events will be attached to make the component work properly
ankio free commented 1 year ago
But I didn't find a way to reinitialize input fileds: https://mdbootstrap.com/docs/standard/forms/input-fields/
但是我没有找到重新初始化输入字段的方法: https://mdbootstrap.com/docs/standard/forms/input-fields/
Grzegorz Bujański staff commented 1 year ago
For inputs, see here: https://mdbootstrap.com/docs/standard/forms/input-fields/#section-dynamic-input-initialization
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Free
- Premium support: No
- Technology: MDB Standard
- MDB Version: MDB5 6.2.0
- Device: Mac
- Browser: Chrome
- OS: MacOS
- Provided sample code: No
- Provided link: No