I need to set an array of data after initializing select2. So I want to make something like this:
var select = $(\'#select\').select2({}); select.data([ {id: 1
Make an element and bind select2 to that. Using .select2 on a regular select box doesn't let you play with the data, it just mostly gives you the UI and post-selection methods.
Source: Select2 Documentation