Topic: select setvalue not working with data-mdb-filter="true"

Coenie Janse van Rensburg priority asked 9 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'); });

Lewis priority answered 1 week ago


I have run into this exact problem!

I am using an ajax call to fill a model window with data once the modal is shown. All is working on expected until I click on the dropdown in the modal.

If I select an option or just click away and open a different modal, the select is the sale value for every modal I open regardless of how I handle it


Kamila Pieńkowska staff commented 1 week ago

Can you provide a snippet that demonstrate the problem?


Lewis priority commented 1 week ago

Not without pulling in AJAX data, it is a modal with data-mdb-id="##" and then on the modal show event trigger, it looks for this id and does and ajax request to push the data into the fields


Kamila Pieńkowska staff commented 1 week ago

Plaese and try to simulate this with JS. We fixed this in version 8.2.0 so it should not happen anymore.


Lewis priority commented 1 week ago

Currently on v8.1.0 so will update and check this, do you not send out emails when new versions are released?


Kamila Pieńkowska staff commented 1 week ago

We send info about new releases only if you subscribed to the newsletter on the changelog page.: https://mdbootstrap.com/docs/standard/getting-started/changelog/


Kamila Pieńkowska staff answered 9 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 9 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 9 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



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: 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