styling to input is not applied when building a dynamic moda


Topic: styling to input is not applied when building a dynamic modal

Yiannis Kyriazidis pro premium priority asked 2 months ago

I am building a modal dynamically with a search input in the modal body. But the styling on the input isnt applied , eg the border of the input via the class="form-outline"

example https://mdbootstrap.com/snippets/standard/yiannis_kyriazidis/3343500#js-tab-view


Grzegorz Bujański staff answered 2 months ago

Dynamically added inputs must be initialized: https://mdbootstrap.com/docs/standard/forms/input-fields/#section-dynamic-input-initialization.

Add this code before opening the modal:

modalWrap.querySelector('.modal').addEventListener('show.mdb.modal', () => {
    document.querySelectorAll('.form-outline').forEach((formOutline) => {
      new mdb.Input(formOutline).init();
    });
  })

Yiannis Kyriazidis pro premium priority answered 2 months ago

ok thanks. tried it and it worked


Please insert min. 20 characters.
Status

Resolved

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.9.0
  • Device: windows desktop
  • Browser: chrome
  • OS: windows
  • Provided sample code: No
  • Provided link: Yes
Tags