Im trying to load the selected values from the database into my multiple select box.
When I load the option initially from the database, It work perfect.
<So after a little help from Mr Arun P Johny
,
I finaly got to the very simple answer.
Maybe I dont fully grasp it yet, but is I understand correctly, you have to approach the loading differently depending if you are creating your Select2
from a input
or a select
.
Mine was created from a select so getting the data back from the AJAX call, I simply used the array containing the ID values of the selected items and passed it through like this
$('#media_keywords').select2().select2('val', keywordArray)
keywordArray
being the array of IDs.