Hello, I’ve this categories array, and i want to make the first element marked as selected on first time, in v5 it was does like this:
<option value="{{value}}" {{#if @first}}selected{{/if}}>
to get
<option value="value" selected>
In V6 i’ve this code , but it doen’t works because don’t put selected in the first option tag:
<select name="event_select" id="event_select">
${categories.value['EVENTS'].map((item, itemIndex) => $h`
<option value="${item.categ_id}" ${itemIndex==0 ? $h`selected`: $h` `}>
${item.categ_title}
</option>
`)}
</select>
This code instead prints testselection=“selected” in first tag and testselection=" " in all the others… the portion of code ${itemIndex==0 ? $h`selected`:` `} is the same in first and second code versions, the only change in second version is that it’s inside testselection="…" to test only… why this doesn’t work if this is outside a parameter?.. the selected parameter needs to be outside like this <option value="" selected>
to work…
<select name="event_select" id="event_select">
${categories.value['EVENTS'].map((item, itemIndex) => $h`
<option value="${item.categ_id}" testselection="${itemIndex==0 ? $h`selected`: $h` `}">
${item.categ_title}
</option>
`)}
</select>
Thanks in advance