Skip to content

Commit

Permalink
Prevent selections from being removed when disabled
Browse files Browse the repository at this point in the history
This prevents selections from being removed when the container is
disabled. This stops any click events that are triggered on the
remove button, so the remove handler won't be triggered at all.

This closes #3636.
  • Loading branch information
kevin-brown committed Aug 20, 2015
1 parent 7d8f86c commit 68d068f
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/js/select2/selection/multiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,26 @@ define([
});
});

this.$selection.on('click', '.select2-selection__choice__remove',
this.$selection.on(
'click',
'.select2-selection__choice__remove',
function (evt) {
var $remove = $(this);
var $selection = $remove.parent();
// Ignore the event if it is disabled
if (self.options.get('disabled')) {
return;
}

var data = $selection.data('data');
var $remove = $(this);
var $selection = $remove.parent();

self.trigger('unselect', {
originalEvent: evt,
data: data
});
});
var data = $selection.data('data');

self.trigger('unselect', {
originalEvent: evt,
data: data
});
}
);
};

MultipleSelection.prototype.clear = function () {
Expand Down

0 comments on commit 68d068f

Please sign in to comment.