Is there any way I can remove an item from Selectize?
Here is my a sample list:
When I pass NA
it should remove particular item:
$.fn.removeSelectorValue = function (value) {
var selectize = this[0].selectize;
selectize.removeItem(value);
return this;
};
This is not working. Can anyone help me with this?
selectize(); var control = $select[0]. selectize; control. clear();
Select remove() Method The remove() method is used to remove an option from a drop-down list. Tip: To add an option to a drop-down list, use the add() method.
$(document).on('click', 'div.selectize-input div.item', function(e) {
var select = $('#services').selectize();
var selectSizeControl = select[0].selectize;
// 1. Get the value
var selectedValue = $(this).attr("data-value");
// 2. Remove the option
select[0].selectize.removeItem(selectedValue);
select[0].selectize.refreshItems();
select[0].selectize.refreshOptions();
});
This code do not remove the item from the select, just remove it from the selected options.
removeItem
removes selected item identified by given value. To remove option from the list you should use removeOption
Example - open http://brianreavis.github.io/selectize.js/, open console and enter:
$('#select-beast')[0].selectize.removeOption(1)
to remove Chuck Tesla from available options
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With