Skip to content

Instantly share code, notes, and snippets.

@lennyburdette
Last active July 10, 2018 22:19
Show Gist options
  • Select an option

  • Save lennyburdette/c0197024ee20058a8f826f7e46c04bd4 to your computer and use it in GitHub Desktop.

Select an option

Save lennyburdette/c0197024ee20058a8f826f7e46c04bd4 to your computer and use it in GitHub Desktop.
focus in events
import Ember from 'ember';
export default Ember.Controller.extend({
logs: [],
actions: {
log(message, event) {
this.set('logs', [...this.logs, message, `Target: ${event && event.target.outerHTML}`]);
}
}
});
<h2>Element Modifier</h2>
<div {{action "log" "on=focusIn works" on="focusIn"}}>
<input />
</div>
<h2>DOM attribute onfocusin</h2>
<div onfocusin={{action "log" "onfocusin= works"}}>
<input />
</div>
<h2>DOM attribute focusin</h2>
<div focusin={{action "log" "onfocusin= works"}}>
<input />
</div>
<h2>DOM attribute onfocus-in</h2>
<div onfocus-in={{action "log" "onfocus-in= works"}}>
<input />
</div>
<h2>DOM attribute onfocus (doesn't bubble)</h2>
<div onfocus={{action "log" "onfocus= works"}}>
<input />
</div>
<h2>DOM attribute onclick</h2>
<div onclick={{action "log" "onclick= works"}}>
<input />
</div>
{{#each logs as |msg|}}
<p>{{msg}}</p>
{{/each}}
{
"version": "0.15.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.2.2",
"ember-template-compiler": "3.2.2",
"ember-testing": "3.2.2"
},
"addons": {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment