My requirement is to add a button or a link when select2 doesn’t find any data from its sources. These are the things I have tried:
- Using lanaguages.noResults properties as seen in https://stackoverflow.com/a/59246687/3687628. This works fine but breaks localization. I cant set language to let’s say french and also display a link when no results are found. The French language is not taken into consideration.
- using open event. The problem here is that it always shows the link. minimumInputLength is 2 so I need at least to hide it till no results come and not when the message says 'please enter 2 or more characters. I tried adding this check but it’s not working as open sometimes the event gets called early on and not exactly when the ‘no results’ element is rendered.
So in short I need to be able to show an anchor tag or a button when I enter more characters more than the minimum number defined and if the result when doing so is 0 records. Any idea how I can achieve this?