stbaer / selectable

Simple helper class to make items selectable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

selectable

Simple single-select for html elements - Examples

stable

Install

NPM

Usage

var Selectable =
require('simple-selectable')

var selectable = new Selectable({
    items: document.querySelectorAll('.items'),
    allowActiveDeselect: false                  //Optional, deselect active item if clicked. Defaults to false,
    });

Listen to changes

selectable.on('selectable.change', function(newItem, oldItem){
          //do sth
       })

items containing a 'disabled' class can't be activated

Destroy

selectable.destroy()

License

MIT

About

Simple helper class to make items selectable

License:MIT License


Languages

Language:JavaScript 95.7%Language:HTML 4.3%