Initialize with some options but use AJAX as the data source


#1

Hi,

I have a Select2 which gets it’s data from an AJAX call but I want it to be initialized with some options.

I have been trying using this: https://select2.org/programmatic-control/add-select-clear-items#preselecting-options-in-an-remotely-sourced-ajax-select2 but it only loads one option, I would like to load multiple.

Is this possible? Do I need to somehow use a data adapter?

Cheers,

Mick


#2

Have you tried simply repeating the procedure to add the remaining initial items? In other words, add one item at a time, and repeat as many times as you need.