Stop suggesting already used tags with ajax

Hi all, one thing that bugs me about Select 2 right now is how with Ajax it will keep suggesting tags you’ve already picked by default.

I’ve tried google/stackoverflow, but I can’t find any existing post about this.

So…how do I tell Select 2 not to suggest what it already has?

Can you be more specific about what you mean by “suggesting”, and “picked by default”? In other words, can you describe exactly (1) the sequence of steps you (as the user) are taking, (2) what Select2 does after each of those steps, and (3) what you expect (or want) Select2 to do instead?

I think there’s a way to solve your problem, but I want to be sure I understand the problem before I offer a solution

As in, you pick “Help” and then start typing “he…” and Help comes up again even though you’ve already picked it as an option.

Thanks for the additional details.

If you supply a custom matcher function you can control which items are matched (shown in the dropdown) as the user types. You would need to keep track of the items that had already been selected, and when those items were passed to your custom matcher you would return null, which instructs Select2 not to display them as selectable options. Of course your function would also be responsible for matching items that should be shown in the dropdown. A substring match between each item’s text and the user’s current search term should be sufficient, especially if your items’ text values use only numbers, unaccented letters, and punctuation.

Good luck!