I'm using the select2 plugin with the property maximumSelectionSize: 1
. After selecting 1, there is an event still on the form that allows the user to click on the outside of the box and a message will appear to say: "You can only select 1 item".
I don't want this message at all. Is there a way I can ensure that this doesn't ever appear?
EDIT - code posted on request:
$('.select2-select').select2({
maximumSelectionSize: 1
});
EDIT 2: aaand a fiddle: http://jsfiddle.net/s85k7tg7/
You could use the select2-opening
event to prevent the drop-down from opening when there is a selected item.
$('.select2-select').select2({
maximumSelectionSize: 1
}).on('select2-opening', function(e) {
if ($(this).select2('val').length > 0) {
e.preventDefault();
}
});
jsfiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With