Creating an Action
Let's create an action in this lesson!
We'll cover the following
Connecting a DOM event to the controller
In Stimulus, an action connects a DOM event to the controller code that you want executed when that event happens. Like controllers, Stimulus actions are also defined using a data attribute in the markup: you add the attribute to the DOM element whose events you want to watch. In our case, that’s the div
element we have styled as a button:
Get hands-on with 1400+ tech skills courses.