Closed suvera closed 8 years ago
You are right, right now this is not possible. The only way to really do this would be to select by value but hypothetically it is possible to have more than one option with the same value. What exactly is your use-case for this? By which criteria would you like to select an entry?
$('#divcontainerid .sol-selection-container').find('input:checkbox[value=yourvalue]:not([disabled], :checked)').prop('checked', true).trigger('change', true);
I need to select certain values by default before showing a popup. This popup has a dynamic form, and I don't wann acreate an ajax just to show the select with proper values. Even though I have already the values
Hi @yessa26
is Boukames solution not working for you?
Hi @pbauerochse
I don't know how to set an Id (to be honest) for the container so I used JS,
/associates is my array with selected values/ var arrayAssociated = document.getElementsByName("associated[]"); for (var i=0; i<associates.length;i++) { for (var j=0; j<arrayAssociated.length;j++){ if(arrayAssociated[j].value == associates[i]) arrayAssociated[j].click(); } }
I used the click event cuz even thought I tried set them as selected, the options were selected on the list but didn't show them on the top of the select. And changing the source didn't work either.
But now it works ')
Look like there is no API/Method to select/unselect options programatically.