After-Actions
After-actions are Actions that can be triggered after an event occurs. For example, you can Perform a request when a user submits the login form.
You can trigger one or more of the following actions after an event occurs:
- Perform a request — Executes a request
- Set cookie — Sets a value for a cookie
- Set variable — Set a value for a variable
- Navigate to — Redirects the user to another page
- Run function — Let's you run any javascript logic
The trigger for your after-action can be any Action with the type of Event, or any On Event Element Action.
Event Action triggers
Here is a list of all of the Event Actions that can be used as a trigger for the Perform request Action:
- Custom Condition: perform actions when a custom condition is met.
- Attribute Present: perform actions when an attribute is present on the page.
- Request Finishes: perform actions when a request finishes.
- Page Starts Loading: perform actions when a page starts loading.
- Page Finishes Loading: perform actions when a page finishes loading.
Element Action triggers - On Event
In addition to the above-mentioned triggers, you can also use the following On Event triggers:
- Click: Acts when the target element is clicked
- Submit: Performs an action when the target form is submitted
- Change: Performs an action when the target input's value changes. Note that this event won't be triggered on every keystroke. Instead, the change event will fire once the input loses focus.
- Input: Performs an action on every keystroke within the target input.
- Blur: Fires once the target input loses focus
- Focus:Acts when the target input gets focus
- Keydown: Performs an action when a key is pressed. This is often paired with conditional logic, to fire only on a specific key like the return key.
- Custom*: You can type in any DOM Event or a custom event that you created. The action will be performed as soon as the event occurs on the target element.
Conditional After-Action Execution
In addition to specifying a trigger, you can add a conditional to any after-action.
Conditional actions will run only if the condition evaluates to true at the moment when the Action is triggered.
For more information on conditionals, head over to the Common Patterns article.