Skip to content

Instantly share code, notes, and snippets.

@mariechatfield
Last active August 6, 2017 00:27
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/04e61443dc21e0198425798fe0511b99 to your computer and use it in GitHub Desktop.
Save mariechatfield/04e61443dc21e0198425798fe0511b99 to your computer and use it in GitHub Desktop.
Ember Events: onClick HTML Attribute
<div class="onclick-attribute" onclick={{action "handleClick"}}></div>
export default Ember.Controller.extend({
actions: {
handleClick(event) {
console.log('This action was fired directly by the browser as part of this DOM event:', event);
}
}
});
<!-- This is what is actually added to the DOM when the template is rendered. -->
<div class="onclick-attribute"></div>
<!--
This element does have a native event listener attached.
You can verify this in your browser's JavaScript console:
> document.getElementsByClassName('onclick-attribute')[0].onclick
function () {
return makeClosureAction(context, targetRef.value(), actionRef.value(), processArgs, debugKey).apply(undefined, arguments);
}
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment