Skip to content

Instantly share code, notes, and snippets.

@mariechatfield
Last active August 6, 2017 00:25
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/54905616e05f17021771fa043b9c387a to your computer and use it in GitHub Desktop.
Save mariechatfield/54905616e05f17021771fa043b9c387a to your computer and use it in GitHub Desktop.
Ember Events: click Component Attribute
{{some-component class="click-attribute" click=(action "handleClick")}}
export default Ember.Controller.extend({
actions: {
handleClick(event) {
console.log('This action was fired by Ember, as a result of a DOM event.');
console.log('This is the original DOM event that is associated with this action: ', event);
}
}
};
<!-- This is what is actually added to the DOM when the template is rendered. -->
<div id="ember328" class="click-attribute ember-view">[... component content ...]</div>
<!--
This element does not have a native event listener attached.
You can verify this in your browser's JavaScript console:
> document.getElementsByClassName('click-attribute')[0].onclick
null
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment