Skip to content

Commit

Permalink
Added onDropdownItemActivate, onDropdownItemDeactivate events
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-maltsev authored and risadams committed Nov 5, 2020
1 parent 98c396b commit 277b234
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ $.extend(Selectize.prototype, {
'type' : 'onType',
'load' : 'onLoad',
'focus' : 'onFocus',
'blur' : 'onBlur'
'blur' : 'onBlur',
'dropdown_item_activate' : 'onDropdownItemActivate',
'dropdown_item_deactivate' : 'onDropdownItemDeactivate'
};

for (key in callbacks) {
Expand Down Expand Up @@ -880,13 +882,17 @@ $.extend(Selectize.prototype, {
var scroll_top, scroll_bottom;
var self = this;

if (self.$activeOption) self.$activeOption.removeClass('active');
if (self.$activeOption) {
self.$activeOption.removeClass('active');
self.trigger('dropdown_item_deactivate', self.$activeOption.attr('data-value'));
}
self.$activeOption = null;

$option = $($option);
if (!$option.length) return;

self.$activeOption = $option.addClass('active');
if (self.isOpen) self.trigger('dropdown_item_activate', self.$activeOption.attr('data-value'));

if (scroll || !isset(scroll)) {

Expand Down

0 comments on commit 277b234

Please sign in to comment.