Skip to content

Feature Request: Make search optional #45

Closed
tedgruenloh opened this Issue Jul 22, 2011 · 24 comments
@tedgruenloh

I love the search feature for long lists of options, but for short lists, it's a bit redundant. And, I'd like to use this plugin on my entire site, for consistency's sake. So, how about a display option that lets you suppress the search on selects that have a small number of options?

@makenosound

+1

@abdulqadir

+1, would be great if I could pass a flag or option when calling the plugin, to control whether or not to have the search input.

@juandazapata

+1

@tarolandia tarolandia added a commit that referenced this issue Jul 23, 2011
@tarolandia tarolandia Catch options, Enable/Disable Search (search_enabled option), Search …
…at start of string (search_at_start option). Related to #45, Related to #29
5117181
@dobeerman

+100500

@edtsech
edtsech commented Jul 24, 2011

+1

@aziz
aziz commented Jul 24, 2011

+1

@glaforge

+1

@tarolandia tarolandia added a commit to tarolandia/chosen that referenced this issue Jul 25, 2011
@tarolandia tarolandia Catch options. Option added: enable/disable search. Option added: sel…
…ect sull search or search at beginnig of words. Related to #45
041f74d
@polarblau

+1

@sehmaschine

+1

@jarink
jarink commented Sep 4, 2011

How to pass that "search_enabled" option ?
Is it $("#myoptions").chosen({"search_enabled" : "false"}) ?

@mtitolo
mtitolo commented Sep 13, 2011

+1

Is this live yet?

@lengarvey

As a work around you can wrap the select in a span then style away div.chzn-search as follows:

<span class='nosearch'> 
  <select class='chzn-select'> 
    <option>Australia</option> 
    <option>New Zealand</option> 
    <option>America</option> 
  </select> 
</span>
.nosearch div.chzn-search {
  display: none;
}
@lmcd
lmcd commented Sep 19, 2011

+1

@gregoryb

+1 ;)

@lorncheung

+1

@pfiller
pfiller commented Sep 30, 2011

Shipped in 1e9b4dd.

You can now have search disable if a select box falls below a certain option threshold. When initializing Chosen, set disable_search_threshold and search will get disabled if the select box had options less than or equal to that number. This way, you can set all of your form fields to use Chosen with the same call and not have to worry about enabling / disabling search on an individual basis.

I made the default for this 0 because I believe search should almost always be turned on... but, I understand that motivation for wanting to turn it off.

@pfiller pfiller closed this Sep 30, 2011
@pfiller pfiller added a commit that referenced this issue Sep 30, 2011
@pfiller pfiller Up version number to 0.9.5
- Allow disabling of Search on single select boxes with <= N options (#45).
- Retain original option styles
- Retain original option classes (#30)
- Fix show results bug when clicking close icon (#277)
1e49c19
@JonoB
JonoB commented Oct 2, 2011

Yay!

@tedgruenloh

Thanks for taking the time. Good work.

@four43
four43 commented Nov 15, 2011

Just came here looking for this. Great feature! Now just update your documentation to reflect your new features you work so hard on! Thanks for the time, looks great.

@NotInUse

Thanks for the reply Jono.. even though I removed my comment. I was silly and failed to update the CSS in addition to the javascript. Once the CSS was updated, all was well. correct usage seems to be ("....").chosen({ disable_search_threshold : 10 });

@Mingun
Mingun commented Oct 15, 2012

This is good, but when entering text filtering occurs, which would like to avoid.

@stof
stof commented Oct 15, 2012

@Mingun There is also an option disable_search now, accepting a boolean

@Mingun
Mingun commented Oct 16, 2012

No, this option only hide text input, but not prevent events, fired by pressing keys. In result, if we have following select structure:

<select>
    <option>YES</option>
    <option>NO</option>
</select>

and start typing Y, then options will be filtered and only option YES will show. And if we start typing, for example, R, then will show No results match "R". This is not the behavior that I would like to, because option disable_search useful for small selects, where filtration is not necessary.

@localpcguy

Just hiding the search presents a problem if using this on mobile, because it immediately pops up the keyboard (focused on the search input.) Looking into what it would take to prevent that focus from happening.

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.