Adding Items to Session Storage Arrays

I tested it today, it is indeed not possible to do it all using the UI. I noticed that you can’t do expressions in the dynamic events and also noticed that some events were missing for the checkbox.

My previous checkbox code was indeed not working, here a working version for the people that are interested.

<input
  type="checkbox"
  name="input1"
  dmx-bind:value="id"
  dmx-bind:checked="arr1.items.contains(id)"
  dmx-on:change="arr1.items.contains(id) ? arr1.remove(id) : arr1.addUniq(id)"
>

An easier way with the UI is indeed to use two buttons and using the contains formatter to show/hide the add/remove button.

<button dmx-hide="arr1.items.contains(id)" dmx-on:click="arr1.add(id)">Add</button>
<button dmx-show="arr1.items.contains(id)" dmx-on:click="arr1.remove(id)">Remove</button>
2 Likes