pawelczak / EasyAutocomplete

JQuery autocomplete plugin
http://easyautocomplete.com
MIT License
729 stars 244 forks source link

Template with icon: possible to change image url dynamically? #463

Open baden32 opened 2 years ago

baden32 commented 2 years ago

The json received with data (not develepped on my side) contains field "type" with a numeric value (1, 3,4, etc.). This info represent a category and I would like to use template iconLeft in order add an icon according to this value.

In my Easycomplete options, I set this:

template: { type: "iconLeft", fields: { iconSrc: "type" } },

As type is only containg a numeric value, no image can be displayed.

So is there a way to dynamically change the received value (in. 2) into a valid image url (ie. /files/images/2.png) ?

Thanks a lot for your help. Joe