Dynamically added select initialisation


Topic: Dynamically added select initialisation

slavaveto asked 3 years ago

I am building a modal dynamically with a select in the modal body. But the styling on the selectisnt applied

how to solve it?


Dawid Wajszczuk staff answered 3 years ago

Hi,

Try this code:

document.querySelectorAll('.select').forEach((select) => {
        const instance = mdb.Select.getInstance(select)
        if (!instance) {
            new mdb.Select(select)
        }
});

Keep coding,
Dawid


slavaveto answered 3 years ago

thanks! it works just fine


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 Standard
  • MDB Version: MDB5 3.9.0
  • Device: MacBook
  • Browser: Chrome
  • OS: MacOs
  • Provided sample code: No
  • Provided link: No
Tags