Remove Button
new TomSelect('#input-tags',{
plugins: {
remove_button:{
title:'Remove this item',
}
},
persist: false,
create: true,
onDelete: function(values) {
return confirm(values.length > 1 ? 'Are you sure you want to remove these ' + values.length + ' items?' : 'Are you sure you want to remove "' + values[0] + '"?');
}
});
<input type="text" id="input-tags" value="awesome,neat" autocomplete="off">
For single selects, you may prefer the Clear Button plugin
new TomSelect('#input-tags2',{
plugins: ['remove_button'],
persist: false,
create: true,
maxItems: 1,
});
<select id="input-tags2" value="awesome" autocomplete="off">
<option>awesome</option>
<option>neat</option>
</select>
Plugin Configuration
Setting | Description |
---|---|
label |
The text that will be displayed in each button
Type:
string
Default:
×
|
title |
The value of the title attribute on each button
Type:
string
Default:
Remove
|
className |
The CSS class name of each button
Type:
string
Default:
remove
|