Skip to content

Support winnowing based on arbitrary undisplayed tags. #628

wants to merge 1 commit into from

10 participants


The checkin implements filtering based on the value of the attribute data-tags on the <option> element, if one is present.

For my app that uses Chosen, I needed to implement filtering the options (a list of people) based on their unaccented version. Instead of trying to strip the accents in Javascript, I figured a simpler, more flexible, and less invasive solution would be to implement filtering based on an arbitrary invisible alternate item key. The key would be generated on the server side as is appropriate for the locale / application, where the libraries for dealing with Unicode are better than in JS.

I tried to preserve the structure of the code as much as possible, the only major change is that the block of code responsible for determining whether an option matches the filter regex in winnow_results() is extracted into the methods option_matches() and option_value_matches() in the class AbstractChosen. Currently, when the match is against the tags, no highlighting of what caused the match is done in the UI.

@millimoose millimoose Support winnowing based on arbitrary undisplayed tags.
During `winnow_results()`, both the HTML and the value of the `data-tags` attribute of an option are matched against the regex. An option is displayed if either of those match.

If an option matches because of its tags, no highlighting takes place.
@pfiller pfiller referenced this pull request May 29, 2012

Keywords support #640



steevel commented Jun 24, 2012







+1 This is also very useful for different spellings of a word. Maybe have your British English spelling as the hidden element and include the American English as the actual option. Colour results in Color. For countries, you can also include the local spelling of the country. България results in Bulgaria.







Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.