Skip to content

Commit 6a1b8d9

Browse files
committed
better comments in example
1 parent 1dae650 commit 6a1b8d9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

examples/custom form component/sqlpage/templates/dual-list.handlebars

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
{{!-- This is a form that will submit data using POST method to the URL specified in the top-level 'action' property coming from the SQL query--}}
1+
{{!-- This is a form that will post data to the URL specified in the top-level 'action' property coming from the SQL query --}}
22
<form method="POST" action="{{action}}">
33
{{!-- Create a row with centered content and spacing between items --}}
44
<div class="row justify-content-center align-items-center g-4">
5-
{{!-- Left List Box (5 columns wide) --}}
5+
{{!-- Left List Box: 5 columns wide (out of the 12 made available by bootstrap) --}}
66
<div class="col-5">
77
{{!-- Card with no border and subtle shadow --}}
88
<div class="card border-0 shadow-sm">
9+
{{!-- Card header with white background, no border, semibold font, and secondary text color --}}
910
<div class="card-header bg-white border-bottom fw-semibold text-secondary py-3">
1011
Available Items
1112
</div>
@@ -66,6 +67,8 @@
6667
{{!-- JavaScript code with CSP (Content Security Policy) nonce for security --}}
6768
<script nonce="{{@csp_nonce}}">
6869
// Get references to both list elements
70+
// If we wanted to be able to include this component multiple times on the same page,
71+
// we would need to generate IDs like "rightList1", "leftList1", etc. using a template string.like "rightList{{@component_index}}"
6972
const rightList = document.getElementById('rightList');
7073
const leftList = document.getElementById('leftList');
7174
@@ -85,6 +88,8 @@
8588
newOptions.sort((a, b) => a.text.localeCompare(b.text));
8689
8790
// Add all options to the destination list
91+
// Since an element can only exist once in the page,
92+
// this will automatically remove the options from the source list
8893
toList.append(...newOptions);
8994
9095
// Focus the destination list and update submit button state
@@ -103,7 +108,7 @@
103108
* Ensure all items in right list are selected before form submission
104109
* This is necessary because unselected options aren't included in form data
105110
*/
106-
function handleSubmit(e) {
111+
function handleSubmit() {
107112
for (const option of rightList.options) option.selected = true;
108113
}
109114

0 commit comments

Comments
 (0)