diff options
Diffstat (limited to 'www/headers')
-rw-r--r-- | www/headers/x-ht-trigger.md (renamed from www/headers/x-kt-trigger.md) | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/www/headers/x-kt-trigger.md b/www/headers/x-ht-trigger.md index 65ad2ed6..55f8b7e8 100644 --- a/www/headers/x-kt-trigger.md +++ b/www/headers/x-ht-trigger.md @@ -1,16 +1,16 @@ --- layout: layout.njk -title: </> kutty - X-KT-Trigger +title: </> htmx - X-HX-Trigger --- -## `X-KT-Trigger` Response Header +## `X-HX-Trigger` Response Header -The `X-KT-Trigger` response header can be used to trigger client side actions from a response to kutty. You can +The `X-HX-Trigger` response header can be used to trigger client side actions from a response to htmx. You can trigger a single event or as many uniquely named events as you would like. To trigger a single event with no additional details you can simply send the header like so: -`X-KT-Trigger: myEvent` +`X-HX-Trigger: myEvent` This will trigger `myEvent` on the triggering element and will bubble up to the body. As an example you could listen for this event like this: @@ -23,7 +23,7 @@ document.body.addEventListener("myEvent", function(evt){ If you want to pass details along with the event, you can move to JSON for the value of the trigger: -`X-KT-Trigger: {"showMessage":"Here Is A Message"}` +`X-HX-Trigger: {"showMessage":"Here Is A Message"}` To handle this event you would write the following code: @@ -36,7 +36,7 @@ document.body.addEventListener("showMessage", function(evt){ Note that the value of the message was put into the `detail.value` slot. If you wish to pass multiple pieces of data you can use a nested JSON object on the right hand side of the JSON object: -`X-KT-Trigger: {"showMessage":{"level" : "info", "message" : "Here Is A Message"}}` +`X-HX-Trigger: {"showMessage":{"level" : "info", "message" : "Here Is A Message"}}` And handle this event like so: @@ -53,6 +53,6 @@ Each property of the JSON object on the right hand side will be copied onto the Finally, if you wish to invoke multiple events, you can simply add additional properties to the top level JSON object: -`X-KT-Trigger: {"event1":"A message", "event2":"Another message"}` +`X-HX-Trigger: {"event1":"A message", "event2":"Another message"}` -Using events gives you a lot of flexibility to add functionality to normal kutty responses.
\ No newline at end of file +Using events gives you a lot of flexibility to add functionality to normal htmx responses.
\ No newline at end of file |