I couldn't find an easy way to write an automatic test for a form using selectize. There's the setTextboxValue but I'm not sure it works completely and it doesn't handle multiple values.
I found a solution (see this SO question) but it would be nice to have a method to set all values at once (or did I miss it?)
There actually is a setValue method that I think is exactly what you're looking for:
var $select = $('select').selectize();
var selectize = $select[0].selectize;
selectize.setValue('single-value');
selectize.setValue(['multiple','values','work','too']);
There's an example of it here: examples/api.html.
I should have mentioned that I tried that.
Now I realize it works if we add the options first. So in my case it's really:
selectize.addOptions([{text: 'Hello', value: 'Hello'}, {text: 'World', value: 'World'}])
selectize.setValue(['Hello', 'World'])
Works for me, thanks.
Most helpful comment
I should have mentioned that I tried that.
Now I realize it works if we add the options first. So in my case it's really:
Works for me, thanks.