forms: keep hint as initial option in dynamic <select> (#37301)
This commit is contained in:
parent
de68242a59
commit
45554f40b0
|
@ -104,7 +104,13 @@ $(function() {
|
|||
// replace <select> contents
|
||||
var $select = $widget.find('select');
|
||||
var current_value = $select.val();
|
||||
var hint = $widget.find('option[data-hint]').data('hint');
|
||||
$select.empty();
|
||||
if (hint) {
|
||||
var $option = $('<option></option>', {value: '', text: hint});
|
||||
$option.attr('data-hint', hint);
|
||||
$option.appendTo($select);
|
||||
}
|
||||
for (var i=0; i<value.items.length; i++) {
|
||||
var $option = $('<option></option>', {value: value.items[i].id, text: value.items[i].text});
|
||||
if (value.items[i].id == current_value) {
|
||||
|
|
Loading…
Reference in New Issue