Edgar Navasardyan
Edgar Navasardyan

Reputation: 4501

Getting the array of selected values of multiple-values selectize

I have a selectize element, and my goal is to get the array of selected objects. $('#my_selectize_input').val() yields "3,4,67". In order to transform it to the necessary form, I use the following:

JSON.stringify($('#my_selectize_input').val().split(',')),

which looks quite awkward. Is there a more elegant way to get the array of selected values ?

Upvotes: 4

Views: 3610

Answers (1)

Koray
Koray

Reputation: 1796

Documentation says "items" is the initial selected values. I'm not exactly sure if this is the answer, but it seems to be working on my tries.

 $('#my_selectize_input')[0].selectize.items

Upvotes: 7

Related Questions