[V6] smartselect trouble

Hello

I have a smartselect with all countries (filled in with the rest service) and I use it on the registration page

I have no preset, so there is an element with the “selected” attribute, but the first element is selected by default. How can you avoid it?

<a class="item-link smart-select smart-select-nazione smart-select-init" data-open-in="popup" data-searchbar="true" data-searchbar-placeholder="Seleziona nazione">
  <select name="country" id="c_country" >
   ${nazioni.value.map((nazione) => $h`
    <option value="${nazione.country_code}">${nazione.country_name}</option>
   `)}
  </select>
  <div class="item-content">
     <div class="item-inner">
        <div class="item-title">${translate('register.country')}</div>
     </div>
  </div>
</a>

works! thanks

@nolimits4web it should be considered as an option to be added natively

Sorry, one more thing
what I wrong with this code?

${nazioni.value.map((nazione) => $h`
   <option value="${nazione.country_code}" ${nazione.country_code == 'IT' && $h`selected`} >${nazione.country_name} </option>
`)}

i’ve tried

${nazione.country_code == ‘IT’ ? ‘selected’ : ‘’}

but nothing. What is correct way to do this with literal templating?

1 Like