Topic: mdb.Select.setValue() not working correctly

dhermann premium asked 1 year ago

Expected behavior const select = document.querySelector('.select'); const singleSelectInstance = mdb.Select.getInstance(select); if (singleSelectInstance) singleSelectInstance.setValue(value);

This code checks to see if there's an mdb.Select instantiated, gets that instance, and sets the value, resulting in the rendered mdb.Select to change which option is displayed as well as the underlying select so I can get the selectedIndex or value later in my code.

Actual behavior

Snippet harness doesn't seem to like function variables? Not sure. Feel free to alter it.

Doesn't change the mdb.Select appearance or element value on my local environment either.

Resources (screenshots, code snippets etc.)

Mateusz Lazaru staff answered 1 year ago

For some reason it's not working via HTML onclick event attribute. This example works fine if you add listener in JS.

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • ForumUser: Premium
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 4.1.0
  • Device: Desktop
  • Browser: Safari
  • OS: macOS Monterrey 12.0.1
  • Provided sample code: No
  • Provided link: Yes