You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature Request: Automatic ID Assignment for TR and TD Elements for HTMX use cases
Summary:
There should be an easy way, or a default setting, for each <tr> element in the table to receive an ID derived from the record. Similarly, each <td> element should also have a unique ID.
Use Case:
Having unique IDs for table rows and cells greatly simplifies the process of targeting specific elements for operations such as updates or deletions. This is particularly useful when using htmx to dynamically replace or update parts of a table.
Current Practice:
Currently, I manually assign IDs to elements, e.g., <tr id="somemodelname-id"> where id is the primary key from the database. This approach makes it easy to target and manipulate elements with htmx.
Similarly, for cells, I use <td id="modelname-cellname-id"> to uniquely identify and target any cell.
Request:
Automatic ID Assignment for <tr> Elements:
Each table row should automatically receive an ID in the format <tr id="modelname-id">, where id is the primary key of the record.
Automatic ID Assignment for <td> Elements:
Each table cell should automatically receive an ID in the format <td id="modelname-cellname-id">, where cellname is the name of the field and id is the primary key of the record.
Component Accessibility:
There should be a way to access the component that renders the <tr> elements, allowing for easy replacement or updates of the entire row when needed.
Benefits:
Simplifies targeting and manipulation of table rows and cells with htmx.
Reduces the need for manual ID assignments, streamlining the development process.
Enhances the ability to dynamically update table content with precision.
The text was updated successfully, but these errors were encountered:
onno-timmerman
changed the title
HTMX TR id (feature request)
HTMX auto id table, tr, td (feature request)
Jul 28, 2024
Feature Request: Automatic ID Assignment for TR and TD Elements for HTMX use cases
Summary:
There should be an easy way, or a default setting, for each
<tr>
element in the table to receive an ID derived from the record. Similarly, each<td>
element should also have a unique ID.Use Case:
Having unique IDs for table rows and cells greatly simplifies the process of targeting specific elements for operations such as updates or deletions. This is particularly useful when using htmx to dynamically replace or update parts of a table.
Current Practice:
Currently, I manually assign IDs to elements, e.g.,
<tr id="somemodelname-id">
whereid
is the primary key from the database. This approach makes it easy to target and manipulate elements with htmx.Similarly, for cells, I use
<td id="modelname-cellname-id">
to uniquely identify and target any cell.Request:
Automatic ID Assignment for
<tr>
Elements:Each table row should automatically receive an ID in the format
<tr id="modelname-id">
, whereid
is the primary key of the record.Automatic ID Assignment for
<td>
Elements:Each table cell should automatically receive an ID in the format
<td id="modelname-cellname-id">
, wherecellname
is the name of the field andid
is the primary key of the record.Component Accessibility:
There should be a way to access the component that renders the
<tr>
elements, allowing for easy replacement or updates of the entire row when needed.Benefits:
The text was updated successfully, but these errors were encountered: