Select2: loading selected values

天大地大妈咪最大 提交于 2019-12-03 21:15:33

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!