Skip to content

Instantly share code, notes, and snippets.

@axelguiloff
Created February 10, 2016 14:43
Show Gist options
  • Save axelguiloff/69debe10df33f516cb1f to your computer and use it in GitHub Desktop.
Save axelguiloff/69debe10df33f516cb1f to your computer and use it in GitHub Desktop.
Autofocus test
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{link-to 'Home' 'home'}} || {{link-to 'Auto test' 'button-test'}}
<br>
<br>
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement() {
console.log('did insert');
this.$('.autotest:first').focus();
this._super(...arguments);
},
actions: {
runAuto() {
console.log('test');
this.$('.autotest:first').focus();
}
}
});
{{input type=text class="autotest"}}
<button {{action "runAuto"}}>Test</button>
{{yield}}
import Ember from 'ember';
export default Ember.Route.extend({
});
import Ember from 'ember';
export default Ember.Route.extend({
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('home');
this.route('button-test');
});
export default Router;
{
"version": "0.5.0",
"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.2.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment