Fastselect is lightweight browser plugin for enhanced select elements based on jQuery. Enables responsive, fast and sensible UI upgrade of select elements with features like option searching and remote dataset loading.
Fast select is not a drop-in replacement for libraries such as Select2, Chosen or Selectize. Goal is to be and remain small both in filesize and api options. As such it can be a reasonable choice for high traffic frontend or simple backend CMS solutions. It weighs less than 5KB (minified and gziped).
Select elements with multiple selectable options are supported by default. Many plugin parameters can be gleaned from input data attributes which can save you from writing configuration code.
Fast select plugin enhances regular select element with UI controls for searching options on the fly. When appropriate options can be loaded via ajax.
Fast select can be instantiated via plugin facade. If there is a need to obtain fastselect object instance you can do so via jquery data utility. Alternatively you can can just use fast select constructor.
var $select = $('select');
// Run, fire and forget
$select.fastselect()
// Run via plugin facade and get instance
var fastSelectInstance = $select.fastselect(options).data('fastselect');
// run directly
var fastSelectInstance = new $.Fastselect($select.get(0), options);
Plugin options / defaults are exposed in $.Fastselect.defaults namespace so you can easily adjust them globally. Full list of options is bellow.
$.Fastselect.defaults = {
elementClass: 'fstElement',
singleModeClass: 'fstSingleMode',
noneSelectedClass: 'fstNoneSelected',
multipleModeClass: 'fstMultipleMode',
queryInputClass: 'fstQueryInput',
queryInputExpandedClass: 'fstQueryInputExpanded',
fakeInputClass: 'fstFakeInput',
controlsClass: 'fstControls',
toggleButtonClass: 'fstToggleBtn',
activeClass: 'fstActive',
itemSelectedClass: 'fstSelected',
choiceItemClass: 'fstChoiceItem',
choiceRemoveClass: 'fstChoiceRemove',
userOptionClass: 'fstUserOption',
resultsContClass: 'fstResults',
resultsOpenedClass: 'fstResultsOpened',
resultsFlippedClass: 'fstResultsFilpped',
groupClass: 'fstGroup',
itemClass: 'fstResultItem',
groupTitleClass: 'fstGroupTitle',
loadingClass: 'fstLoading',
noResultsClass: 'fstNoResults',
focusedItemClass: 'fstFocused',
matcher: null,
url: null,
loadOnce: false,
apiParam: 'query',
initialValue: null,
clearQueryOnSelect: true,
minQueryLength: 1,
focusFirstItem: false,
flipOnBottom: true,
typeTimeout: 150,
userOptionAllowed: false,
valueDelimiter: ',',
maxItems: null,
parseData: null,
onItemSelect: null,
onItemCreate: null,
onMaxItemsReached: null,
placeholder: 'Choose option',
searchPlaceholder: 'Search options',
noResultsText: 'No results',
userOptionPrefix: 'Add '
};
For browser usage browse dist folder - if working with build tools go with src folder. Fastselect uses Fastsearch library internaly for querying and rendering options. Download library files from github repo, get them via bower (bower install fastselect) or via npm (npm install fastselect)