bigskysoftware / htmx-extensions

164 stars 50 forks source link

Class tools clasess event #83

Open n4j1Br4ch1D opened 3 months ago

n4j1Br4ch1D commented 3 months ago

On event trigger class manipulation

This feature allows for dynamic class manipulation in response to specific events using the classes-event-trigger or data-classes-event-trigger attribute.


<!-- The following performs class manipulation only after the event is triggered -->
<div hx-ext="class-tools">
    <div classes="add foo:1s" classes-event-trigger="my-custom-event">Class foo wil be added after 1s</div> <!-- Adds the class "foo" 1 second after the event is triggered -->
    <div classes="toggle foo:!" classes-event-trigger="my-custom-event">Class foo wil be toggled</div> <!-- "!" means toggle immediately with no delay -->
    <div classes="toggle foo:!, toggle bar:!" classes-event-trigger="my-custom-event">Class foo & bar wil be toggled</div> <!-- toggles multiple classes -->
    <button hx-on-click="htmx.trigger('body', 'my-custom-event')">toggle</button>
</div>
netlify[bot] commented 3 months ago

Deploy Preview for htmx-extensions ready!

Name Link
Latest commit 28ab422199d60114410b6fe67431e70ea5cceb4f
Latest deploy log https://app.netlify.com/sites/htmx-extensions/deploys/66c202ab7f12df000818085b
Deploy Preview https://deploy-preview-83--htmx-extensions.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.