Secondary initialize "mdb-select" is possible

Boris Akimenko pro asked 5 months ago

Hi guys!
Secondary initialized  $('.mdb-select').material_select(); gives multiple material view on already initialized selects.

So if I dynamically add some <select> element, then I have to get this element and initialize it instead just run $('.mdb-select').material_select().


Hi Boris,

Can You try to give select a new class each time You add the next select? Then You can initialize only this select without changing the others.

Regards


Alex Gotardi pro answered 4 months ago

Boris,

See https://mdbootstrap.com/support/fix-multi-material-select/

or destroy and create mdb-select, but's more expensive to browser cpu-usage

 

// Material Select Destroy $('.mdb-select').material_select('destroy');

Mikołaj Smoleński commented 4 months ago

Thanks for sharing Your solution!


Boris Akimenko pro commented 4 months ago

Thank you Alex!
But destroy is not good way as you say :)
Init function must check selects by class which added when it initialized


Mikołaj Smoleński commented 4 months ago

Boris, is Alex solution working in Your project?


Please insert min. 20 characters.
Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No