Fix incorrect Handlebars context reference in input names
Updated the Handlebars template to correctly reference the parent context for `item_id` using `../item_id` instead of `item_id`. This ensures the input field names are properly constructed within nested loops, avoiding potential data binding issues.
This commit is contained in:
@@ -11,14 +11,14 @@
|
||||
<tbody>
|
||||
{{#each collection}}
|
||||
<tr>
|
||||
<td><input type="text" name="{{item_id}}-id-{{@index}}" value="{{id}}"></input></td>
|
||||
<td><input type="text" name="{{item_id}}-label-{{@index}}" value="{{label}}"></input></td>
|
||||
<td><input type="text" name="{{../item_id}}-id-{{@index}}" value="{{id}}"></input></td>
|
||||
<td><input type="text" name="{{../item_id}}-label-{{@index}}" value="{{label}}"></input></td>
|
||||
<td><button id="delete-row-{{@index}}" class="delete-row"><i class="delete-row fa-solid fa-trash-can"></i></button></td>
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr>
|
||||
<td><input type="text" name="{{item_id}}-id-0" value="" placeholder="id"></input></td>
|
||||
<td><input type="text" name="{{item_id}}-label-0" value="" placeholder="label"></input></td>
|
||||
<td><input type="text" name="{{../item_id}}-id-0" value="" placeholder="id"></input></td>
|
||||
<td><input type="text" name="{{../item_id}}-label-0" value="" placeholder="label"></input></td>
|
||||
<td><button id="delete-row-0" class="delete-row"><i class="delete-row fa-solid fa-trash-can"></i></button></td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
|
||||
Reference in New Issue
Block a user