Skip to content

Enhancement: trigger multiple events #15

@euri10

Description

@euri10

Summary

from the docs here https://htmx.org/headers/hx-trigger/

Multiple Triggers
If you wish to invoke multiple events, you can simply add additional properties to the top level JSON object:

HX-Trigger: {"event1":"A message", "event2":"Another message"}

You may also trigger multiple events with no additional details by sending event names separated by commas, like so:

HX-Trigger: event1, event2

Using events gives you a lot of flexibility to add functionality to normal htmx responses.

I dont see a way to achieve that, is that possible ?
adding manually the headersshould solve it, for instance this is ok, the commented part is what I would have originally written, passing headers works fine

        return HTMXTemplate(
            template_name="rbac_user_role_permissions.html",
            context={"user_role_permissions": user_role_permissions},
            # # trigger_event="update_user_roles,update_role_permissions",
            # after="swap",
            headers={"HX-Trigger-After-Swap": "update_user_roles, update_role_permissions"}
        )

if not im fancy implementing it since I selfishly need it :)

Basic Example

No response

Drawbacks and Impact

No response

Unresolved questions

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions