Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


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


lemons free 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,


lassekofoed free answered 5 years ago



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

  • 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