Topic: select setvalue not working with data-mdb-filter="true"
Coenie Janse van Rensburg priority asked 4 months ago
inside a modal the setvalue works when data-mdb-filter="false" but when true then it doesn't set the value.
Expected behavior is with data-mdb-filter="true" the set value should still work
https://mdbootstrap.com/snippets/standard/coenie_janse_van_rensburg/6136039
Launch demo modal
Modal title One Two Three Four Five Example label reset/close Save changes // Initialize the MDB select instance const singleSelect = document.querySelector('#singleSelection'); const singleSelectInstance = mdb.Select.getInstance(singleSelect); // Add event listener to the button const resetBtn = document.getElementById('resetbtn'); resetBtn.addEventListener('click', () => { singleSelectInstance.setValue('1'); });Kamila Pieńkowska staff answered 4 months ago
I don't understand the problem. Your snippet works like you describe you want it to work.
I've changed value set vie reset button to 2 to see result when I use reset button and it works.
Also if you need to reset value to first option you can use clear button: https://mdbootstrap.com/docs/standard/forms/select/#section-clear-button
Coenie Janse van Rensburg priority commented 4 months ago
Did you even try the snippet? Open the modal select value three for enstance click reset/close button the value is supposed to be reset to 1(Option 1). The value is not resetting,
if i turn data-mdb-filter="true" to false then the search function is gone and when i select a value again like three or something and click reset button then the value reset perfect back to 1.
Kamila Pieńkowska staff commented 4 months ago
As I wrote I did try is. But I change value to 2. This wont work for value '1'. It's due to specifics of HTML select tag.
If you want reset button to clear select use this:https://mdbootstrap.com/snippets/standard/kpienkowska/6136726
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 7.3.0
- Device: mac
- Browser: chrome
- OS: senoma
- Provided sample code: No
- Provided link: Yes