Topic: Append new Material select after initialized the first one, doesn't work.
aklaunch free asked 5 years ago
Expected behavior Initialize the Material select and then append new Material select to the page. and the new Material select will work fine and will show up the options. Actual behavior After initialize Material select all work fine. but after appending new Material select to the body the new Material select doesn't open and not working at all. i tried to destroy the Material select and initialize again but it did not help.
Resources (screenshots, code snippets etc.)
Mateusz Łubianka staff answered 4 years ago
Hi @pavan_kp,
You should add id for new select:
elem.setAttribute("id", x);
And init by ID:
$(`#${x}`).materialSelect();
If it isn't any solution of your problem please, create a snippet showing your problem here: https://mdbootstrap.com/snippets/. I'll try to help you.
Best,
lassekofoed free answered 4 years ago
Maybe this can help you https://mdbootstrap.com/support/jquery/append-copy-of-mdb-select-not-working-i-4-8-10/
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 jQuery
- MDB Version: 4.10.1
- Device: browser
- Browser: chrome
- OS: windows
- Provided sample code: No
- Provided link: No
lemons free commented 5 years ago
you can give the dynamically added select an ID and then initialize only this select $('#dynamicallyAddedSelect').materialSelect();