Example of working with component focus events.
View Twiddle | Copy Twiddle | View Gist
Original idea of this README taken from @rwjblue
Example of working with component focus events.
View Twiddle | Copy Twiddle | View Gist
Original idea of this README taken from @rwjblue
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: ['focus-box'], | |
attributeBindings: ['tabindex'], | |
'tabindex': 1000, | |
hasFocus: false, | |
focusIn(){ | |
this.set('hasFocus', true); | |
}, | |
focusOut() { | |
this.set('hasFocus', false); | |
} | |
}); |
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
background: #444; | |
color: #f0bf50; | |
} | |
.focus-box { | |
padding: 1em; | |
border: 1px solid #bbb; | |
background: #666; | |
} | |
.focus-box:focus { | |
outline: none; | |
} |
{ | |
"version": "0.6.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.3.1/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.3.3/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js" | |
} | |
} |