Skip to content

Proposal: Add htmx.dispatch / HX-Dispatch aliases (disambiguating from hx-trigger) #3964

Description

@AndrewGit25

Motivation

Using the same term for both listening (hx-trigger) and firing (htmx.trigger / HX-Trigger) creates cognitive friction:

  • hx-trigger is passive listening (e.g., "when event X happens, trigger this request").

  • htmx.trigger / HX-Trigger is active dispatching (e.g., "fire/dispatch event X now").

Proposed Alternative Names

  • htmx.dispatch() / HX-Dispatch (matches native DOM dispatchEvent and Alpine.js)

  • htmx.emit() / HX-Emit

  • htmx.fire() / HX-Fire

Mental Model

  • hx-trigger="change": Listen for the change event, then issue the request.

  • htmx.dispatch(elt, "myEvent"): Dispatch myEvent on the target element.

  • HX-Dispatch: "myEvent": Instruct the client to dispatch myEvent on the <body>.

Proposal

Consider introducing HX-Dispatch / htmx.dispatch() either as:

  1. Aliases alongside HX-Trigger / htmx.trigger() for better DX and backwards compatibility, or

  2. A naming convention change considered for future major version roadmaps.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions