Ember 4.6 <select> not showing current value

Viewed 19

Am I missing something in the following:

<select
  id={{@field}}
  name={{@field}}
  {{on "change" this.sendSelect}}
>
  <option value="null">Select one ... </option>
  {{#each this.data as |item|}}

  {{log "in record.hbs, curVal=" @curVal}}
  {{log "in record.hbs, item.id=" item.id}}
  {{debugger}}
    <option
      value={{item.id}}
      selected={{fn this.areEqual @curVal item.id}}
    >{{item.name}}</option>
  {{/each}}
</select>

The selected option is not being identified when the is first loaded. The {{log}} statements show that one of the records have @curVal and item.id having equal values. Using the {{debugger}} and

typeof  get(item.id)

and the same for @curVal shows they are both strings.

I originally used ember-truth-helpers, with

{{eq  @curVal item.id}}

but that never selects anything. So I wrote a local function:

@action
  areEqual(curval, itemId) {
    console.log('typeof curval', typeof curval);
    console.log('typeof itemId', typeof curval);
    return curval == itemId;
} 

but it never seems to be called. What am I doing wrong?

1 Answers
Related