Vdom select option selected

this should be very simple but somehow i just cant get it working

${list && $h`
        ${list.map((item, k) => $h`
            <td class="label-cell">${item.user}</td>
            <td class="label-cell">${item.prodName}</td>
            <td class="label-cell">
              <div class="input-dropdown-wrap"><select name="status${k}" class="field " @change="${() => save(k)}">
                ${optStatus.map((item2) => $h`
                  <option value="${item2.k}" ${item2.k == item.status ? 'selected="selected"' : ''}>${item2.v}</option>
        ${list.length == 0 ? $h`
          <tr><td colspan="6">${app.f7.mod.helper.lng('noEntries')}</td></tr>
        ` : ''}

the selected="selected is never outputed, if i remove the white space
<option value="${item2.k}"${item2.k == item.status ? 'selected="selected"' : ''}>${item2.v}
then it is rendered in the value attribute option. i have also tried with “$h” in if but nothing changed.

the same problem with checkboxes, it seams the render method isnt accepting my attribute. i would expect there to be an easy way so mark inputs as selected in virtual dom. it must be something small and stupid that i am just not seeing

<option value="${value}" selected=${condition}>

i tried but it didnt help, i cant do ${condition} because i am in a loop in the middle of the template
<option value="${item2.k}" selected=${item2.k == item.status ? ‘selected’ : ‘false’}>${item2.v}

<option value="${item2.k}" selected=${item2.k == item.status}>
1 Like

this does it, it is confusing that the inspector doesn’t see any of the markup none the less the correct option is selected. thanks!