Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Getting Started

Karl edited this page Jun 15, 2017 · 3 revisions

Install with bower

bower install mobius1-selectr --save

Install with npm

npm install mobius1-selectr --save

Manual Installation

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

Initialisation

HTML

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>

Javascript

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.