@dariovinci/bs-multiselect
v1.0.5
Published
A simple and light multiselect for bootstrap written in JS
Downloads
3
Maintainers
Readme
Wrap an input (an optionally a label) field in a div and choose an id. Example: multiselect-test
<div id="multiselect-users-wrapper">
<input type="text" class="form-control">
<label for="multiselect-users">Utenti</label>
</div>
You can also use bs-multiselect with form floating. Example:
<div id="multiselect-test">
<div class="form-floating">
<input type="text" class="form-control">
<label for="multiselect-users">Utenti</label>
</div>
</div>
Then in your js file add:
const multiselect_test = new BsMultiselect({
inputId: '#multiselect-test',
dataArray: [],
selectAll: true,
showCompactSelection: true,
maxHeight: 200px,
showSearchBox: true,
});
const multiselect_test = new BsMultiselect({
inputId: '#multiselect-test',
dataArray: [],
selectAll: true,
showCompactSelection: true,
maxHeight: 200px,
showSearchBox: true,
ajaxCreateDataArray: (resp) => {
let dataArray = [];
for (let i = 0; i < resp.length; i++) {
const element = resp[i];
dataArray.push({
value: element.id,
text: element.name
})
}
return dataArray;
}
});