Skip to content

Instantly share code, notes, and snippets.

@jcfranco
Forked from nwhittaker/controllers.application\.js
Last active April 12, 2022 17:59
Show Gist options
  • Save jcfranco/0791820b770b9d5b547dc3f36556f24f to your computer and use it in GitHub Desktop.
Save jcfranco/0791820b770b9d5b547dc3f36556f24f to your computer and use it in GitHub Desktop.
Input focus change
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
export default class ApplicationController extends Controller {
@tracked seededValue
@action seedValueWithFocusShift() {
document.getElementById('seeded').setFocus()
this.seededValue = Math.random()
}
@action didChangeSeededInput() {
console.log('didChangeSeededInput')
}
init() {
super.init()
const script = document.createElement('script')
script.type = 'module'
script.src = 'https://unpkg.com/@esri/calcite-components@next/dist/calcite/calcite.esm.js'
document.head.appendChild(script)
const link = document.createElement('link')
link.rel = 'stylesheet'
link.href = 'https://unpkg.com/@esri/calcite-components@next/dist/calcite/calcite.css'
document.head.appendChild(link)
}
}
<p>
<calcite-button {{on 'click' this.seedValueWithFocusShift}}>
<span>Seed value <em>with</em> focus shift</span>
</calcite-button>
</p>
<calcite-label>
Seeded value
<calcite-input
id="seeded"
value={{this.seededValue}}
{{on 'calciteInputChange' this.didChangeSeededInput}}></calcite-input>
</calcite-label>
{
"version": "0.17.1",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
"ember": "3.18.1",
"ember-template-compiler": "3.18.1",
"ember-testing": "3.18.1"
},
"addons": {
"@glimmer/component": "1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment