Topic: How to create element dynamically?

KES free asked 3 years ago


Hi.

Is there a way to create components dynamically?

like: new Select({ ...options })


Grzegorz Bujański staff answered 3 years ago


Yes, it is possible. First you need to add select HTML code, then init it:

const mySelect = new mdb.Select(document.getElementById('mySelect'), options)

Here you will find an example: https://mdbootstrap.com/snippets/standard/grzegorz-bujanski/3205320#js-tab-view

You can add other components dynamically in a similar way. In the API tab of the component documentation, you will find the JS code required to init the component



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 Standard
  • MDB Version: MDB5 3.8.1
  • Device: no device
  • Browser: FF
  • OS: Linux mint 19.3
  • Provided sample code: No
  • Provided link: No