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:
parent
7d8f86cbf8
commit
68d068f1d2
12
src/js/select2/selection/multiple.js
vendored
12
src/js/select2/selection/multiple.js
vendored
@ -32,8 +32,15 @@ define([
|
||||
});
|
||||
});
|
||||
|
||||
this.$selection.on('click', '.select2-selection__choice__remove',
|
||||
this.$selection.on(
|
||||
'click',
|
||||
'.select2-selection__choice__remove',
|
||||
function (evt) {
|
||||
// Ignore the event if it is disabled
|
||||
if (self.options.get('disabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $remove = $(this);
|
||||
var $selection = $remove.parent();
|
||||
|
||||
@ -43,7 +50,8 @@ define([
|
||||
originalEvent: evt,
|
||||
data: data
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
MultipleSelection.prototype.clear = function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user