ben
December 20, 2023, 12:40am
1
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
ben
December 20, 2023, 6:17am
3
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
Teodor
December 20, 2023, 7:27am
5
ben:
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.
Hi Ben, is this input inside a repeat region?
bpj
December 20, 2023, 7:49am
6
@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?
Teodor
December 20, 2023, 8:23am
8
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.
ben
December 20, 2023, 9:04am
9
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