slim-select icon indicating copy to clipboard operation
slim-select copied to clipboard

Issue with innerHTML (no result shown)

Open yellow1912 opened this issue 4 years ago • 3 comments

When the innerHTML is supplied, it seems like Slim tries to match the text inside the returned data and if the innerHTML does not contains the term then it returns nothing. I believe this behavior is incorrect especially for AJAX search for 2 reasons:

  1. With ajax search, the callback method already takes care of the search/filter, the returned data passed to it should be the entire result. No further filtering should be necessary.
  2. The innerHTML is just a template for displaying the selection, using the content of the innerHTML to filter is just wrong. For example, I could decide to use an image for each selection, that doesn't mean that Slim should try to match the values using innerHTML, it should still use the value property.

yellow1912 avatar Nov 15 '19 12:11 yellow1912

I tried to use searchFilter call back, but something is very weird. When innerHTML is preset, the text property is set to the content of innerHTML as well.

image

yellow1912 avatar Nov 15 '19 14:11 yellow1912

Can you send some gifs of what your getting and what you expect to happen please?

brianvoe avatar Nov 15 '19 16:11 brianvoe

Hi Brian,

I think there are 2 issues to consider here:

  1. Inside an option object, if innerHtml is available then it seems like the plain text version of the innerHtml is extracted and used to override the text value. Let's say I have this scenario where I have a list of persons, I want to display the person avatar using the innerHtml but I want to use the person name (which is passed into the text field) to filter then it's not possible. Another option is to allow passing arbitrary meta value to the option object to use in the search filter. I think this is what select2 jQuery plugin allows.

  2. Another issue is the search filter function itself when used with ajax option. Normally when we populate data via ajax, we already take the search term and do the filter via the back end, so the data from ajax callback should not be refiltered anymore. Anyhow this can be overriden by always returning true in the searchFilter callback.

Overall, I think allowing passing meta value to option object is easy fix and can solve all the issues.

yellow1912 avatar Nov 16 '19 04:11 yellow1912

New version of slim select has been released. If this is still an issue let me know and ill try to take care of it.

brianvoe avatar Nov 21 '22 01:11 brianvoe