Topic: autocomplete displayValue and store Idvalue
Hi, I'm rewriting my old jQuery autocompletes to use mb5, and I'm having a problem meeting the requirements.
displayValue van be used when a complex object is used.
I'm looking for a way that I can do something with another attribute from that selected complex object , other than de value I want displayed. For example, let's say de object holds an 'Id' that I want to pass to another function when the user makes his item selection.
e.g.
id name
1001, "jarjar"
1002, "tarkin"
-
new mdb.Autocomplete(asyncAutocomplete, {
filter: asyncFilter,
displayValue: (value) => value.name });
now i'm looking for something like this ;
myAutocomplete.addEventListener('close.mdb.autocomplete', (e) => {
// do something with (value) => value.id })
basicly the behaviour a
<select>
<option value=1001>jarjar</option>
</select>
would produce.
Grzegorz Bujański staff answered 4 years ago
Check the solution from this snippet: https://mdbootstrap.com/snippets/standard/grzegorz-bujanski/2882079 I understand that you meant something like that?
kreuze pro premium priority answered 4 years ago
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Resolved
- User: Pro
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: 1.0.0
- Device: all
- Browser: all
- OS: windows
- Provided sample code: No
- Provided link: No