slim-select
slim-select copied to clipboard
Issue with innerHTML (no result shown)
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:
- 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.
- 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.
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.
Can you send some gifs of what your getting and what you expect to happen please?
Hi Brian,
I think there are 2 issues to consider here:
-
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.
-
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.
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.