I have a custom multi-select field. When I open a piece of content that has previously been saved, the selected value is not highlighted. The correct value is stored correctly in content and appears correctly in the field's value attribute. The "selected" attribute even gets placed on the correct option when the content opens, but it is not actually highlighted.
I haven't been able to find any good documentation on the this, so what I have is mostly copied directly from how dotCMS handles regular Multi-select fields. Below is my code for the custom field value:
<script>
function updatelocationMultiSelect() {
var valuesList = "";
var multiselect = $('locationSelect');
for(var i = 0; i < multiselect.options.length; i++) {
if(multiselect.options[i].selected) {
if (valuesList != ""){
valuesList += ","
}
valuesList += multiselect.options[i].value;
}
}
$('location').value = valuesList;
}
updatelocationMultiSelect();
</script>
<select name="locationSelect" dojoType="dijit.form.MultiSelect" id="locationSelect" onchange="updatelocationMultiSelect" size="10" multiple="multiple" value="$location">
#foreach($con in $dotcontent.pull("+contentType:Location +(conhost:SYSTEM_HOST)",50,"Location.title"))
#set($locationList = "$con.title ($con.airportCode)")
<option #if($locationList == $location) selected #end value="$!{con.title} ($!{con.airportCode})">$con.title ($con.airportCode)</option>
#end
</select>
Any help would be appreciated.
Thanks!
--Tad Luedtke