I am using the select2 plugin which allows me to set a default value for a multiple select as follows:
$('#myID').select2('val', ['val1','val2','val3',...]);
This works fine so far but when I try to use a variable instead of hard-coding the different vals then it fails so I guess I am passing the variable the wrong way. Can someone here help me with this ?
I tried:
var myVar = "['val1','val2','val3']";
$('#myID').select2('val', myVar);
Many thanks in advance for any help with this, Tim.