Topic: autocomplete displayValue and store Idvalue

kreuze priority asked 3 years ago

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.


 id        name 
 1001, "jarjar"  
 1002, "tarkin"


 new mdb.Autocomplete(asyncAutocomplete, {   
 filter: asyncFilter,  
 displayValue: (value) => });

now i'm looking for something like this ;

 myAutocomplete.addEventListener('close.mdb.autocomplete', (e) => {
//  do something with  (value) => })

basicly the behaviour a

<option value=1001>jarjar</option>

would produce.

Grzegorz Bujański staff answered 3 years ago

Check the solution from this snippet: I understand that you meant something like that?

kreuze priority answered 3 years ago

That's it exactly ! Many thanks !!

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: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: 1.0.0
  • Device: all
  • Browser: all
  • OS: windows
  • Provided sample code: No
  • Provided link: No