-
Notifications
You must be signed in to change notification settings - Fork 610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to customize dropdown list (add images, etc) #16888
Comments
It is, as of v1.1!! @vlazar, could you explain how, since you added that feature? |
It may be possible, since we have separated List of items provided via However, since we also support string based v1.0 API we wrap items internally with special As workaround, if you only need text and image, you can use @LeaVerou I think we should definitely try to extend Awesomplete for this case, so that any property in original list will be accessible in custom functions. |
+1 for making all properties accessible |
@rightaway The following options should work for you then: list: [ { value: 'Text for dropdown and input field', label: 'http://example.com/img.jpg' }, ...],
item: function (suggestion, input) {
// notice the use of suggestion.value here, default function effectively uses suggestion.label
var html = input === '' ? suggestion.value : suggestion.value.replace(RegExp($.regExpEscape(input), "gi"), "<mark>$&</mark>");
// here you will have image URL in suggestion.label property, so you can add it to LI
return $.create("li", {
innerHTML: html,
"aria-selected": "false"
});
},
filter: function(suggestion, input) {
// the default function uses suggestion.label here as well, so we need to override this too
return Awesomplete.FILTER_STARTSWITH(suggestion.value, input);
} |
Hey guys, thanks for the script. This is what I ended up doing for my purposes:
The data is in this format:
I couldn't figure out how to have more than just the value/label parameters for each item so ended up having to just store all components in the label field and then splitting it out :) |
hi,@rightaway,can you tell me how to add an image to the list item next to the text.I did something with the code like: |
I think @vlazar is more appropriate to help you here, since he wrote the separate label/value feature. |
@JronZhu You'll need to provide custom However a best way would be to allow arbitrary properties for items. See #16888 (comment) |
@vlazar Thanks for your helps.I customized data/filter/item function to successfully add images in the dropdown list.data:set label and value property;filter:change the match way;item:change the way to generate the item. It is great! |
@JronZhu would you mind sharing your code here? Looking for the same behaviour :) |
So is this feature implemented or not? The comments suggest that its is implemented, but the issue is still marked as If it is implemented, I wonder if there is any online example that shows how it works? |
@JronZhu Can you tell me how did you add the images next to text dynamically? I'm returning the results via Google Map API. |
my solution works but i can't remove MARK
|
In the dropdown list of suggestions, instead of just text appearing is it possible to have images next to the text? For example, if the dropdown contains a list of food, there could be a small picture of that food item next to it. Is it possible to do or could this feature be added?
The text was updated successfully, but these errors were encountered: