-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
4.0
-
None
-
MOODLE_400_STABLE
I'm using Moodle's Autocomplete element using a select with a defined list of options, I don't use an AJAX call to load them. There are cases where there will be no selected option, but the Autocomplete element automatically displays either the first or the last option as selected.
If I define all the options with no selected attribute (e.g. <option value="x">) then Autocomplete detects the first option as selected. If I define all options with selected="false" then Autocomplete detects the last option as selected. I'm not sure if this is caused by jQuery or by the HTML itself, this line says true for the first or last option.
IMO if there is no option specified as selected the Autocomplete should display the no selection string, as it does when you remove the selected option.
This is my Mustache code:
<select id="assignedto-select" class="form-autocomplete-original-select">
#assignableusers
<option value="id"#selected}}selected{{/selected>fullname</option>
/assignableusers
</select>
And this is my JS code:
Autocomplete.enhance('#assignedto-select', false, '', placeholderString, false, true, undefined, true);