luci-base: ui.js: mark widget optional if empty choice is present
Fixes: #2943 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
b20f000c85
commit
360e9769d6
1 changed files with 4 additions and 1 deletions
|
@ -223,6 +223,9 @@ var UISelect = UIElement.extend({
|
|||
widget: 'select',
|
||||
orientation: 'horizontal'
|
||||
}, options);
|
||||
|
||||
if (this.choices.hasOwnProperty(''))
|
||||
this.options.optional = true;
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
@ -243,7 +246,7 @@ var UISelect = UIElement.extend({
|
|||
'multiple': this.options.multiple ? '' : null
|
||||
}));
|
||||
|
||||
if (this.options.optional || this.choices.hasOwnProperty(''))
|
||||
if (this.options.optional)
|
||||
frameEl.lastChild.appendChild(E('option', {
|
||||
'value': '',
|
||||
'selected': (this.values.length == 0 || this.values[0] == '') ? '' : null
|
||||
|
|
Loading…
Reference in a new issue