Chosen automatically sets the default field text ("Choose a country...") by reading the select element's data-placeholder value. If no data-placeholder value is present, it will default to "Select an Option" or "Select Some Options" depending on whether the select is single or multiple. You can change these elements in the plugin js file as you see fit.
+
<select data-placeholder="Choose a country..." style="width:350px;" multiple class="chosen-select">
+
Note: on single selects, the first element is assumed to be selected by the browser. To take advantage of the default text support, you will need to include a blank option as the first element of your select list.
When a single select box isn't a required field, you can set allow_single_deselect: true and Chosen will add a UI element for option deselection. This will only work if the first option has blank text.
When working with form fields, you often want to perform some behavior after a value has been selected or deselected. Whenever a user selects a field in Chosen, it triggers a "change" event* on the original form field. That let's you do something like this:
+
$("#form_field").chosen().change( … );
+
Note: Prototype doesn't offer support for triggering standard browser events. Event.simulate is required to trigger the change event when using the Prototype version.
+
+
+
Updating Chosen Dynamically
+
If you need to update the options in your select field and want Chosen to pick up the changes, you'll need to trigger the "chosen:updated" event on the field. Chosen will re-build itself based on the updated content.
Yes! Please report all issues using the GitHub issue tracking tool. Please include the plugin version (jQuery or Prototype), browser and OS. The more information provided, the easier it is to fix a problem.
+
+
+
What browsers are supported?
+
All modern desktop browsers are supported (Firefox, Chrome, Safari and IE9). Legacy support for IE8 is also enabled. Chosen is disabled on iPhone, iPod Touch, and Android mobile devices (more information).
When set to true on a single select, Chosen adds a UI element which selects the first element (if it is blank).
+
+
+
disable_search
+
false
+
When set to true, Chosen will not display the search field (single selects only).
+
+
+
disable_search_threshold
+
0
+
Hide the search input on single selects if there are fewer than (n) options.
+
+
+
enable_split_word_search
+
true
+
By default, searching will match on any word within an option tag. Set this option to false if you want to only match on the entire text of an option tag.
+
+
+
inherit_select_classes
+
false
+
When set to true, Chosen will grab any classes on the original select field and add them to Chosen’s container div.
+
+
+
max_selected_options
+
Infinity
+
Limits how many options the user can select. When the limit is reached, the chosen:maxselected event is triggered.
+
+
+
no_results_text
+
"No results match"
+
The text to be displayed when no matching results are found. The current search is shown at the end of the text (e.g.,
+ No results match "Bad Search").
+
+
+
placeholder_text_multiple
+
"Select Some Options"
+
The text to be displayed as a placeholder when no options are selected for a multiple select.
+
+
+
placeholder_text_single
+
"Select an Option"
+
The text to be displayed as a placeholder when no options are selected for a single select.
+
+
+
search_contains
+
false
+
By default, Chosen’s search matches starting at the beginning of a word. Setting this option to true allows matches starting from anywhere within a word. This is especially useful for options that include a lot of special characters or phrases in ()s and []s.
+
+
+
single_backstroke_delete
+
true
+
By default, pressing delete/backspace on multiple selects will remove a selected choice. When false, pressing delete/backspace will highlight the last choice, and a second press deselects it.
+
+
+
width
+
Original select width.
+
The width of the Chosen select box. By default, Chosen attempts to match the width of the select box you are replacing. If your select is hidden when Chosen is instantiated, you must specify a width or the select will show up with a width of 0.
+
+
+
display_disabled_options
+
true
+
By default, Chosen includes disabled options in search results with a special styling. Setting this option to false will hide disabled results and exclude them from searches.
+
+
+
display_selected_options
+
true
+
+
By default, Chosen includes selected options in search results with a special styling. Setting this option to false will hide selected results and exclude them from searches.
+
Note: this is for multiple selects only. In single selects, the selected result will always be displayed.
+
+
+
+
include_group_label_in_selected
+
false
+
+
By default, Chosen only shows the text of a selected option. Setting this option to true will show the text and group (if any) of the selected option.
The text to be displayed as a placeholder when no options are selected for a select. Defaults to "Select an Option" for single selects or "Select Some Options" for multiple selects.
+
Note:This attribute overrides anything set in the placeholder_text_multiple or placeholder_text_single options.
+
+
+
+
multiple
+
The attribute multiple on your select box dictates whether Chosen will render a multiple or single select.
+
+
+
selected, disabled
+
Chosen automatically highlights selected options and disables disabled options.
Chosen triggers the standard DOM event whenever a selection is made (it also sends a selected or deselected parameter that tells you which option was changed).
+
Note: in order to use change in the Prototype version, you have to include the Event.simulate class. The selected and deselected parameters are not available for Prototype.
+
+
+
+
chosen:ready
+
Triggered after Chosen has been fully instantiated.
+
+
+
chosen:maxselected
+
Triggered if max_selected_options is set and that total is broken.
+
+
+
chosen:showing_dropdown
+
Triggered when Chosen’s dropdown is opened.
+
+
+
chosen:hiding_dropdown
+
Triggered when Chosen’s dropdown is closed.
+
+
+
chosen:no_results
+
Triggered when a search returns no matching results.
+
+
+
+
+ Note: all custom Chosen events (those that being with chosen:) also include the chosen object as a parameter.
+
You can trigger several events on the original select field to invoke a behavior in Chosen.
+
+
Example:
+
+
+ // tell Chosen that a select has changed
+ $('.my_select_box').trigger('chosen:updated');
+
+
+
+
+
Event
Description
+
+
+
chosen:updated
+
This event should be triggered whenever Chosen’s underlying select element changes (such as a change in selected options).
+
+
+
chosen:activate
+
This is the equivalant of focusing a standard HTML select field. When activated, Chosen will capure keypress events as if you had clicked the field directly.
+
+
+
chosen:open
+
This event activates Chosen and also displays the search results.
+
+
+
chosen:close
+
This event deactivates Chosen and hides the search results.
Here you will find a table of aliases available in the Census module. If a module is marked as "normalizable" the data returned will include *VARIABLE_NAME*_normalized, which will be that variable divided by the appropriate geographical population.
Number - The latitude of the requested location (North). Also supported: latitude, y
+
+
+
Number - The longitude of the requested location (East). Also supported: longitude, x
+
+
+
+
+
+
zip:
+
+
+
+
+
+
String - The 5-digit zip code of the location. Note that USPS zip code areas do not align precisely with Census geographies, so when high accuracy is required it is recommended to use latitude and longitude. Specified as a string because certain zip codes begin with zeroes.
+
+
+
+
+
state:
+
+
+
+
+
+
String - The 2-letter USPS state code. It will be converted into the latitude and longitude of that state's capital.
+
+
+
+
+
+
Street:
+
+
+
City:
+
+
+
State:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Object - Represents the address of the requested location.
+
+
+
+
+
variables:
+
+
+
+
+
+
+
Array - Optional - An array of strings specifying which variables to query. One can specify an aliased variable (see variable aliases) or a specific ACS variable code (e.g. "B01003_001E"). If this array is not specified, the SDK will simply geocode the location into Census FIPS codes. A list of all ACS variables is available on the Census's developer portal or via the SDK's getACSVariableDictionary method.
+
+
+
+
+
level:
+
+
+
+
+
+
String - At what level to request the data. These are based on census geographies. Supported options are: "blockGroup", "tract", "county", "state", "us", and "place". Note that the "place" tag currently only supports incorporated places.
+
+
+
+
+
sublevel:
+
+
+
+
+
+
Boolean - Optional Whether or not to return based upon sublevels. See sublevel requests for more information. Defaults to false.
+
+
+
+
+
container:
+
+
+
+
+
+
String - Optional, GeoJSON request only - Specifies a level which serves as a boundary for a GeoJSON request. For instance, if your level is "tract" and your container is set as "place" with sublevel enabled, it the SDK will return all tracts which fall within or touch that place's geographical boundaries. The container tag says "get all level within container", a place is the census word for an incorporated city, and sublevel says "get all of that level"