Skip to content

Instantly share code, notes, and snippets.

@mariechatfield
Last active August 6, 2017 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariechatfield/ad3c99550a5e880bafd75c8e6deb4ab3 to your computer and use it in GitHub Desktop.
Save mariechatfield/ad3c99550a5e880bafd75c8e6deb4ab3 to your computer and use it in GitHub Desktop.
Ember Events: Element Modifier
<div class="element-modifier" {{action "handleClick"}}></div>
export default Ember.Controller.extend({
actions: {
handleClick() {
console.log('This action was fired by Ember, as a result of a DOM event.');
console.log('This action does not have access to the original DOM event associated with it.');
}
}
});
<!-- This is what is actually added to the DOM when the template is rendered. -->
<div class="element-modifier" data-ember-action="" data-ember-action-317="317"></div>
<!--
This element does not have a native event listener attached.
You can verify this in your browser's JavaScript console:
> document.getElementsByClassName('element-modifier')[0].onclick
null
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment