1
0
mirror of synced 2025-02-04 06:09:23 +03:00

Prevent selections from being removed when disabled

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 https://github.com/select2/select2/pull/3636.
This commit is contained in:
Kevin Brown 2015-08-19 21:01:19 -04:00
parent 7d8f86cbf8
commit 68d068f1d2

View File

@ -32,8 +32,15 @@ define([
}); });
}); });
this.$selection.on('click', '.select2-selection__choice__remove', this.$selection.on(
'click',
'.select2-selection__choice__remove',
function (evt) { function (evt) {
// Ignore the event if it is disabled
if (self.options.get('disabled')) {
return;
}
var $remove = $(this); var $remove = $(this);
var $selection = $remove.parent(); var $selection = $remove.parent();
@ -43,7 +50,8 @@ define([
originalEvent: evt, originalEvent: evt,
data: data data: data
}); });
}); }
);
}; };
MultipleSelection.prototype.clear = function () { MultipleSelection.prototype.clear = function () {