Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTMX auto id table, tr, td (feature request) #954

Open
onno-timmerman opened this issue Jul 28, 2024 · 0 comments
Open

HTMX auto id table, tr, td (feature request) #954

onno-timmerman opened this issue Jul 28, 2024 · 0 comments

Comments

@onno-timmerman
Copy link

onno-timmerman commented 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"> 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:

  1. 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.

  2. 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.

  3. 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.
@onno-timmerman onno-timmerman changed the title HTMX TR id (feature request) HTMX auto id table, tr, td (feature request) Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant