You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem:
When acting on the onItemRemove callback, only the value of the option is passed. This doesn't allow us to know which selectized element this remove was performed on.
Other callbacks like onItemAdd(value, $item) return the $item.
I believe all the callbacks should return this information when available wether it's usefulness is immediately obvious or not.
Adding this information to callback is extremely trivial.
Simply adding , $item to the self.trigger('item_remove', value); function will do the trick:
/**
* Removes the selected item matching
* the provided value.
*
* @param {string} value
*/
removeItem: function(value) {
var self = this;
var $item, i, idx;
$item = (typeof value === 'object') ? value : self.getItem(value);
value = hash_key($item.attr('data-value'));
i = self.items.indexOf(value);
if (i !== -1) {
$item.remove();
if ($item.hasClass('active')) {
idx = self.$activeItems.indexOf($item[0]);
self.$activeItems.splice(idx, 1);
}
self.items.splice(i, 1);
self.lastQuery = null;
if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
self.removeOption(value);
}
if (i < self.caretPos) {
self.setCaret(self.caretPos - 1);
}
self.refreshState();
self.updatePlaceholder();
self.updateOriginalInput();
self.positionDropdown();
self.trigger('item_remove', value, $item);
}
},
The text was updated successfully, but these errors were encountered:
Problem:
When acting on the
onItemRemove
callback, only the value of the option is passed. This doesn't allow us to know which selectized element this remove was performed on.Other callbacks like
onItemAdd(value, $item)
return the $item.I believe all the callbacks should return this information when available wether it's usefulness is immediately obvious or not.
Adding this information to callback is extremely trivial.
Simply adding
, $item
to theself.trigger('item_remove', value);
function will do the trick:The text was updated successfully, but these errors were encountered: