How to preload aui select2 and then load more options dynamically

I have a field, enabled aui select2 (multiple: false) on it. I want to preload it with results. When user clicks on the field, it shall show preload data and then append more results only when searched text does not match preloaded results.

As of now it works like reloads the results on every search.

Is there a way to update results/options of aui-select2?


Hi @sunita,

It sounds like you’re after either a custom query function for your Select2 control, or passing a data array to the control. The Select2 documentation explains how to do these things: