Cannot update the variable

OS info

Problem description

with this line of code, I want to update varTotal:

<input type="hidden" id="amount" name="amount" dmx-bind:value="(price * quantity)" dmx-bind:id="'inp_amount'+$index" dmx-on:updated="varTotal.setValue(varTotal.value + value.toNumber())">

The update to varTotal does not happen.

@ben I tried it in w6.0.0 beta8 stable and got the same NaN value for for the variable…
But I tried to add a debounce on the updated event, starting from 20 and increase.
EDIT: It works when debounce=100 and the value is updated

1 Like

Thank you Tasos for putting in the time and effort to help me out.

I reverted to the stable version and even without debounce, the code does work.

I guess that App Connect 2 has not caught up yet.

1 Like

Hi Ben, is this input inside a repeat region?

@ben
Is the dmx-bind:value evaluating correctly - could the price or quantity be a string? What does the element look like in the browser dev console’s HTML?

Is it possible that you post the whole code involved, as i just tested this code with an input inside a repeat region and the varTotal is updated perfectly fine.

:blush:

I spent hours on the problem, left for dinner, had a nap and returned to Wappler.

Problem gone. All works as expected. Thanks all for your input in helping this codger.

Update: This is the code

            <div class="row">
                <div class="col">
                    <table class="table">
                        <thead>
                            <tr>
                                <th class="visually-hidden">Header</th>
                                <th class="w-50">Name</th>
                                <th class="text-end">Price</th>
                                <th class="text-center">Qty</th>
                                <th class="text-end">Amount</th>
                            </tr>
                        </thead>
                        <tbody is="dmx-repeat" dmx-generator="bs5table" dmx-bind:repeat="dsCart.data" id="tableRepeat2">
                            <tr>
                                <td class="visually-hidden">
                                    <dmx-data-view id="data_view1" dmx-bind:data="serverconnectProducts.data.queryProducts" filter="id"></dmx-data-view>
                                </td>
                                <td dmx-text="data_view1.data[0].name"></td>
                                <td dmx-text="data_view1.data[0].price" class="text-end"></td>
                                <td dmx-text="quantity" class="text-center"></td>
                                <td class="text-end">
                                    <input type="hidden" id="amount" name="amount" dmx-bind:value="(data_view1.data[0].price * quantity)" dmx-bind:id="'inp_amount'+$index" dmx-on:updated="varTotal.setValue(varTotal.value + value.toNumber())">
                                    <p dmx-text="amount.value.toNumber().formatCurrency('$', '.', ',', 2)">A nice paragraph</p>
                                </td>
                            </tr>
                        </tbody>
                        <tfoot>
                            <tr>
                                <td colspan="5" class="text-end">
                                    <p class="fw-bold">Total Payable {{varTotal.value.toNumber().formatCurrency('$', '.', ',', 2)}} </p>
                                </td>
                            </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
2 Likes