Skip to content

Instantly share code, notes, and snippets.

@tgaff
Created March 30, 2022 19:50
Show Gist options
  • Save tgaff/de37872f5de47a6eb506a8b0bb133b47 to your computer and use it in GitHub Desktop.
Save tgaff/de37872f5de47a6eb506a8b0bb133b47 to your computer and use it in GitHub Desktop.
stimulus

naming

multi word controllers

Controller named complex_thing_controller.ts

doBigThing() {}
<div data-controller="complex-thing"> 
  <span data-action='click->complex-thing#doBigThing'`>click me</span>
</div>

action methods

jump(event) {
  event.target // received the event (likely a child-element)
  event.currentTarget // is the element where the stimulus binding caught the event
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment