Using HTML element event properties such as onclick
for Ember actions is not recommended for the following reasons:
- It doesn't work for SVGs (since there is no
onclick
property ofSVGElement
). - It can lead to confusing and unexpected behavior when mixed with normal action usage. For a comprehensive explanation of why, read Deep Dive on Ember Events.
The recommended alternative is the on
modifier. on
is available in Ember 3.11+ and by polyfill for earlier versions.
This rule forbids the following:
This rule allows the following:
- Documentation for template actions
- Polyfill for the
on
modifier (needed below Ember 3.11) - Spec for the
on
modifier - Spec for the
action
modifier - List of DOM Events
- Deep Dive on Ember Events