'Preload options to Ajax select2
I'm using a select2 ajax based dropdown with a single select. This is working perfectly. There is another input field also on the page and when this is interacted with, I would like to preload the select with a certain amount of options - say 4. I am using the below to insert the options dynamically, but this is only presenting 1 selected option and when I click the dropdown I get the "please enter x characters" message and don't see what I've preloaded. Is this something that can be achieved?
var newOption = new Option(data.text, data.id, true, true);
$('#selectid').append(newOption).trigger('change');
Thanks, David
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
