I am using the excellent select2 jquery plugin to select tags.
I am not able to find a way to limit the results (say to first 5 only).
My code:
var tags = []; // this array is filled with user's tags
$("#tags").select2({
minimumInputLength: 2,
placeholder: 'tags',
tags: tags,
tokenSeparators: [",", " "],
closeOnSelect: false
});
Any ideas?
see maximumSelectionSize
option, if you want to limit the number of results that can be selected
How about
tags = tags.slice(0, 5);
wherever relevant in your context.
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