Im fairly confident this isnt a bug and just a missed step on my end, but if it is a missed step I can not figure out what it is.
I am trying to set up a scenario where when one checkbox is checked it checks one or many other checkboxes, and when one or many of those second checkboxes is checked it shows a hidden button.
A typical use case for this would be a table containing a checkbox on each row and a select all checkbox in the header, where when one or many of the row checkboxes is checked it shows a hidden button that is outside of the table (i.e. “delete selected,” or “approve selected,” etc), and when the header checkbox is checked it checks all of the row checkboxes, thus also showing the hidden button.
The problem I am encountering is when checking the header checkbox it does check the row checkboxes but the button is not shown, however, if the checkboxes in the rows are checked individually the button shows as expected. This is being done by changing the value of a variable through a dynamic event on checked, but when the checkbox is checked from the header checkbox it appears this event is not triggered because the variable doesn’t change, yet the checked state and the value still does. =/
I set up the scenario as a single stand-alone container for simplicity. Here is the code and some screenshots:
<div class="d-flex justify-content-around flex-row">
<div class="d-flex">
<dmx-value id="var1" dmx-bind:value="0"></dmx-value>
<p dmx-text="'Var Value: '+var1.value">Enter your content here</p>
</div>
<div class="d-flex flex-column">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="input1" name="input1" dmx-bind:value="checked.toNumber()">
<label class="form-check-label" for="input1">Default checkbox</label>
</div>
<p dmx-text="'Value: '+input1.value+' // Checked State: '+input1.checked">Enter your content here</p>
</div>
<div class="d-flex flex-column">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="input2" name="input2" dmx-on:checked="var1.setValue((var1.value + 1))" dmx-on:unchecked="var1.setValue((var1.value - 1))" dmx-bind:checked="input1.checked" dmx-bind:value="checked.toNumber()">
<label class="form-check-label" for="input2">Default checkbox</label>
</div>
<p dmx-text="'Value: '+input2.value+' // Checked State: '+input2.checked">Enter your content here</p>
</div>
<div class="d-flex flex-column"><button id="btn4" class="btn btn-primary" dmx-hide="(var1.value < 1)">Button</button></div>
Nothing selected:
Input2 selected; everything as expected, with variable value updated:
Page refreshed, input1 selected; input2 as expected, with value change and correct state, but variable value unchanged, thus button still hidden:
I just don’t understand what else to try here, since the dynamic event is on checked it should update the variable value, and the checked state is correct so I have no idea why the dynamic event for checked state is not running to update that variable value. =/