V6: smart Select, mark first element as selected option

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 :slight_smile:

I’ve change the code to new this version, and it works and don’t… it put selected in the code to the first element as expected, but it don’t show the first element as selected in the smart Select…

     <select name="event_select" id="event_select">
          ${categories.value['EVENTS'].map((item, itemIndex) => $h`
            ${itemIndex==0 ? $h`
                <option value="${item.categ_id}" selected>
                  ${item.categ_title}
                </option>
            `: $h`
                <option value="${item.categ_id}">
                  ${item.categ_title}
                </option>
            `}
          `)}
      </select>

Hello:
I’ve similar problem in this case, for some logic features some parameters are obtained from the database in a “extra” field… I put the data like this <a ${menu[‘menu_extra_parameters’]}>, but the data is not procesed, like in the previous example with the selected option, this happens when I dont put the ${menu[‘menu_extra_parameters’]} field inside a parameter; if i do this way: <a extra="${menu[‘menu_extra_parameters’]}"> it works and render the menu_extra_parameters content, but it’s not render if i don’t put it inside the extra="…" or something:

   <div class="list links-list">
      <ul>
        ${menus.value['left_panel'].map((menu) => $h`
        <li>

              <a href="${menu['menu_link']}" class="${menu['menu_class']}"

                ${(menu['menu_html_id'] != null && menu['menu_html_id'] != "") ? $h`
                  id="${menu['menu_html_id']}"
                ` : $h`  `}


                ${(menu['menu_extra_parameters'] != null) ? $h`
                  ${menu['menu_extra_parameters']}
                ` : $h`  `}

              >${menu['menu_title']}</a>

        </li>
        `)}
      </ul>
    </div>