This repository was archived by the owner on Dec 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
Getting Started
Karl edited this page Jun 15, 2017
·
3 revisions
bower install mobius1-selectr --save
npm install mobius1-selectr --save
Include the CSS file ...
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/mobius1/selectr@latest/dist/selectr.min.css">
... and the JS file...
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/mobius1/selectr@latest/dist/selectr.min.js"></script>
CDN courtesy of jsDelivr
Start with a standard select box you want to convert:
<select id="mySelect">
<option value="1">Value 1</option>
<option value="2">Value 2</option>
<option value="3">Value 3</option>
...
</select>
You can then instantiate Selectr by passing a reference to your select box as the first parameter:
You can either pass a DOM node or a CSS3 selector string:
new Selectr(document.getElementById('mySelect'));
// or
new Selectr('#mySelect');
Selectr accepts a second parameter as an object with the options you want to set:
new Selectr('#mySelect', {
searchable: false,
width: 300
});
You can view the available options here.
- defaultSelected
- multiple
- searchable
- clearable
- allowDeselect
- width
- placeholder
- maxSelections
- taggable
- tagSeperators
- tagPlaceholder
- data
- renderOption
- renderSelection
- pagination
- nativeDropdown
- closeOnScroll
- sortSelected
- customClass
- messages