In this video, Emmanuel Henri introduces how to set up the state and initialize it with some values.
- [Instructor] So, let's start working on the state…for the first, initialized method;…so the first thing we'll do, is go inside of our index,…here, and we'll make sure that in the actual…card title, so if we scroll up here, we have a card title…here; if we take a look at the actual UI, here,…we have a card title; I'd like to be able to control…this card title with my input here, so that's the idea,…so the first thing we'll do, is add something here,…as opposed to card title, if there's no input,…and when there's an input, then change it to the input…that we've entered.…
Again, we're gonna use this state to do all this,…so let's go back here, and let's here, in the span…of the card title, change this to nothing,…so remove this first, and then, in the actual span,…we'll do a data-name equals Manny Henri,…so that doesn't change anything on the UI, in fact,…you should see nothing in the UI once we refresh,…because there's nothing, so what we'll do now,…is start working with the controller, to add some stuff…in this particular area, when it meets certain conditions.…
- Why use Stimulus?
- Adding and using controllers
- The role of identifiers
- Using targets and actions
- Working with the state in Stimulus
- Persisting the state in the DOM