Skip to content
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

Search from the option beginning #878

Closed
STIGiampaolo opened this issue Oct 25, 2012 · 5 comments
Closed

Search from the option beginning #878

STIGiampaolo opened this issue Oct 25, 2012 · 5 comments

Comments

@STIGiampaolo
Copy link

It should be useful having the possibility of searching only from the beginning of the option.

For example:

Polar bear
Giant Panda

If I start searching with 'P', I'd like to find only 'Polar bear' and not both.

@qool
Copy link

qool commented Oct 25, 2012

I would really appreciate this function too! :)
To have an option to disable fulltext-like search, because this is normal behavior of standart select box.

EDIT:
I have found undocumented option "search_contains" discussed at http://drupal.org/node/1470556 and #288.
When set to true, search is looking for string containing the search term, otherwise it should work as normal search from beginning.

BUT when I init selectbox like this:

$(".chzn-select").chosen({search_contains:false});

... it doesnt change the default Chosen search (contains) behavior... What Im doing wrong?

@stof
Copy link
Collaborator

stof commented Nov 29, 2012

@Qoolture search_contains: false is the default value. If you set it to true, it will match any option containing the string instead of matching only on the beginning of words

@styfle
Copy link

styfle commented Dec 11, 2012

@stof Thanks I was looking for this. Where is the documentation for Chosen options?

@pfiller
Copy link
Contributor

pfiller commented Dec 11, 2012

I don't think search_contains: true is what you want here. When you use search_contains, Chosen will match any part of the word instead of starting from the beginning of words. Taking your example with search_contains on means that a search of "anda" would match "Giant Panda".

What you really want to use is disable_search_split_words: true. This will tell Chosen to skip searching word parts. When combined with search_contains: false (the default), you will get a search that starts only from the beginning of a string.

One thing to note is that the disalbe_search_split_words variable name is going to change in next couple of days - see PR #940.

@pfiller pfiller closed this as completed Dec 11, 2012
@pfiller
Copy link
Contributor

pfiller commented Dec 11, 2012

Oh - forgot to address "Where is the documentation for Chosen options?" The docs are sorely in need of an update and hopefully that will happen soon. Feel free to weigh in on #671 (the official documentation thread).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants