Append new Material select after initialized the first one,


Topic: Append new Material select after initialized the first one, doesn't work.

aklaunch 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.)


lemons commented 5 years ago

you can give the dynamically added select an ID and then initialize only this select $('#dynamicallyAddedSelect').materialSelect();


Mateusz Łubianka staff answered 5 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,


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: 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