Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prefix string matching using Chosen jQuery plugin

We are using the Chosen jquery plugin for converting a long options list of the select element into a searchable autocomplete input field.

Is it possible to influence/configure the matching behavior of search terms? Right now Chosen seems to split all option terms into words and performs a prefix search on all words of an option term. The desired behavior we need is to have a prefix search on the option term only. So search for "Island" should match an option like

Island of ....

Island of Hope

Island of Disaster

but not

Easter *Island*s


1 Answers

Today I used Chosen jQuery Plugin and faced the same issue it was searching string in option term prefix.

Searching for the solution I found it was a registered issue at GitHub.

The solution was using search_contains option.

And I solved the problem by using following configuration.

$("select").chosen({enable_split_word_search:true,search_contains:true});
like image 67
Irfan DANISH Avatar answered May 27 '26 20:05

Irfan DANISH