Frage

In the next listbox I load elements with template:

<listbox model="@load(vm.resAccepted)" selectedItem="@bind(vm.selResAccepted)">
  <template name="model">
    <listitem>
      <listcell label="@load(each.eventName)" />
      <listcell label="@load(each.userName)" />
      <listcell>
        <button image="/img/button_mail.png"/>
      </listcell>
    </listitem>
  </template>
</listbox>

My goal is to enable the button of the listitem ONLY for the row the user selects.

To do this, I try

<button disabled="@load(vm.selResAccepted.id=each.id?'false':'true')" />

checking if the unique field id is the same of the selected element, but it fails.

Any help will be appreciated.

War es hilfreich?

Lösung

You can use eq for equals comparison:

<button disabled="@load(vm.selResAccepted.id eq each.id?'false':'true')" />

or maybe even better: disabled when selected item is not the current item

<button disabled="@load(vm.selResAccepted ne each)" />

here ne is not equal

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top