Event Handlers
In this lesson, you’ll learn how to define and use event handlers in an Ember application.
We'll cover the following
In the Components chapter we got away with defining the event handler for DOM events inline using the set
helper. Here, however, we’ll need to define the actions ourselves.
Currently, since we haven’t written the actions, we get the following error:
Assertion failed: You must pass a function as the second argument to the
on
modifier.
The error is due to the fact that this.updateTitle
, this.saveSong
, and this.cancel
are all undefined. Therefore, we have to define them in the template’s context. Remember what that context is? Yep, the controller.
Actions
Let’s open the controller file and define these new event handlers:
Get hands-on with 1200+ tech skills courses.