Cmd+Enter to Submit Forms | SupeRails #212

11/11/2024
stimulusjs
  • (BAD) Targets and Event listeners
  • (BETTER) data-action in view, keyboard logic in stimulus
  • (BEST) Stimulus keyboard events

We will explore 3 different ways of solving the same problem with StimulusJS.

I think solving the same problem with different approaches is a great way to learn.

0:00 (BAD) Targets and Event listeners
3:40 (BETTER) data-action in view, keyboard logic in stimulus
5:05 (BEST) Stimulus keyboard events

Stimulus keyboard event docs: https://stimulus.hotwired.dev/reference/actions#keyboardevent-filter
Blogpost: https://blog.corsego.com/stimulus-cmd-enter-to-submit
Source code: https://github.com/corsego/212-stimulus-keyboard-submit/commit/98126bb58effc79439d235d02cc8f9f2028dda48

0
Sign in to join the conversation