Skip to content

Latest commit

 

History

History
38 lines (25 loc) · 1.53 KB

no-element-event-actions.md

File metadata and controls

38 lines (25 loc) · 1.53 KB

no-element-event-actions

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 of SVGElement).
  • 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.

Examples

This rule forbids the following:

<button onclick={{action "submit"}}>Submit</button>

This rule allows the following:

<button {{on 'click' this.submit}}>Submit</button>

References

Related Rules