Skip to content

Instantly share code, notes, and snippets.

@vinilios
Last active August 5, 2016 07:35
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 vinilios/4fdeb3957d7123ba13c4b9882bdaa2d3 to your computer and use it in GitHub Desktop.
Save vinilios/4fdeb3957d7123ba13c4b9882bdaa2d3 to your computer and use it in GitHub Desktop.
test-focus-invalidation
import Ember from 'ember';
export default Ember.Component.extend({
init: function() {
this._super();
console.log("lala");
},
tagName: 'button',
classNameBindings: ['focused:focus'],
click: function(event) {
this.sendAction('onClick', this);
},
focusIn: function() {
this.set('focused', true);
},
focusOut: function() {
this.set('focused', false);
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
observeClicked: Ember.observer('clicked', function() {
this.set('buttons', [0, 0, 0]);
}),
buttons: [1,2,3,4,5],
clicked: false,
actions: {
onClick: function(but) {
this.set('clicked', true);
}
}
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
button.focus {
color: #f00;
}
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{#each buttons as |button|}}
{{#my-but onClick=(action 'onClick')}}
click me {{ button }}
{{/my-but}}
{{/each}}
<br>
<br>
{
"version": "0.10.4",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.7.0",
"ember-data": "2.7.0",
"ember-template-compiler": "2.7.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment