mirror of
https://github.com/s00500/ESPUI.git
synced 2025-07-04 11:20:19 +00:00
Preselect the right option in the select-input
This commit is contained in:
@ -648,6 +648,15 @@ void ESPUIClass::jsonDom( AsyncWebSocketClient* client ) {
|
||||
item["parentControl"] = String( control->parentControl );
|
||||
}
|
||||
|
||||
// special case for selects: to preselect an option, you have to add "selected" to <option>
|
||||
if ( control->type == ControlType::Option ) {
|
||||
if ( ESPUI.getControl( control->parentControl )->value == control->value ) {
|
||||
item["selected"] = "selected";
|
||||
} else {
|
||||
item["selected"] = "";
|
||||
}
|
||||
}
|
||||
|
||||
items.add( item );
|
||||
|
||||
control = control->next;
|
||||
|
Reference in New Issue
Block a user