Limited checkbox mithril component.
$ npm install git://github.com/inotom/limbox.git#v2.0.0 --save-dev
import m from 'mithril';
import Limbox from 'limbox';
let names = ['Orange', 'Apple', 'Grape', 'Lemon', 'Banana'];
let checkedIndexes = m.prop([]);
m.mount(document.body, {
view: () => {
return m('div', [
m(Limbox, {
max: 2,
groupName: 'fruit[]',
names: names,
onchange: function(checkedList) {
checkedIndexes = checkedList;
}
}),
m('ul', checkedIndexes.map(function(index) {
return m('li', names[index]);
}))
]);
}
});
Parameter | Mandatory | Type | Default | Description |
---|---|---|---|---|
max |
optional | Number | 2 |
Max size of selectable item |
groupName |
optional | String | limbox[] |
Element name attribute |
names |
Array required | Array | Array of item label text and value text | |
onchange |
optional | Function | Callback function |
MIT
iNo