Skip to content

Instantly share code, notes, and snippets.

@gabrielgrant
Last active January 16, 2019 15:54
Show Gist options
  • Save gabrielgrant/6f82aa1cce20e0831e285c172ca7e998 to your computer and use it in GitHub Desktop.
Save gabrielgrant/6f82aa1cce20e0831e285c172ca7e998 to your computer and use it in GitHub Desktop.
Checkbox Focus test
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Checkbox focus test',
actions: {
focusInAction() {
let args = Array.from(arguments)
let alerts = this.get('alerts');
this.set('alerts', alerts + '\nFocused: ' + args.join(', '));
console.log(args, arguments);
}
}
});
<h1>Welcome to {{appName}}</h1>
For checkboxes <code>focus-in</code> doesn't work:
<br>
<label>
{{input type="checkbox" focus-in=(action 'focusInAction')}}
focus-in checkbox
</label>
<br>
<br>
but <code>focusIn</code> does:
<br>
<label>
{{input type="checkbox" focusIn=(action 'focusInAction')}}
focusIn checkbox
</label>
<br>
<br>
For text inputs, however, both work:
<br>
<label>
{{input type="text" focus-in=(action 'focusInAction')}}
focus-in text input
</label>
<br>
<br>
<label>
{{input type="text" focusIn=(action 'focusInAction')}}
focusIn text input
</label>
<br>
Note, though, that argument passed to the handlers is different (current value vs jquery event; details in the console):
<pre>
{{alerts}}
</pre>
{
"version": "0.13.0",
"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.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.16.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment