Checkboxes: Difference between revisions
Jump to navigation
Jump to search
(Created page with "<strong>Use BoostrapVue's checkbox:</strong> <b-form-checkbox v-model="isBar" > Bar </b-form-checkbox> Confusingly, it can also be <b-checkbox> (src). Tab navigation. See Tab Key Navigation section. To navigate away from the dropdown, define the keydown event handler: private onKeyDownFooCheckbox(e: KeyboardEvent) { this.emulateTab( e, () => { (this.$refs.barField as any).$el.focus(); (this.$refs.barField as any).$el.select(); }, () =>...") |
No edit summary |
||
(17 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<strong>Use BoostrapVue's checkbox:</strong> | <strong>Use BoostrapVue's checkbox:</strong> | ||
<b-form-checkbox | |||
<pre><b-form-checkbox | |||
v-model="isBar" | v-model="isBar" | ||
> | ></pre> | ||
</b-form-checkbox> | Bar | ||
<pre></b-form-checkbox></pre> | |||
Confusingly, it can also be <b-checkbox> (src). | Confusingly, it can also be <b-checkbox> (src). | ||
Tab navigation. See Tab Key Navigation section. To navigate away from the dropdown, define the keydown event handler: | |||
private onKeyDownFooCheckbox(e: KeyboardEvent) { | <strong>Tab navigation.</strong> See Tab Key Navigation section. To navigate away from the dropdown, define the keydown event handler: | ||
<pre>private onKeyDownFooCheckbox(e: KeyboardEvent) | |||
{ | |||
this.emulateTab( | this.emulateTab( | ||
e, | |||
() => { | () => { | ||
(this.$refs.barField as any).$el.focus(); | (this.$refs.barField as any).$el.focus(); | ||
Line 19: | Line 25: | ||
(this.$refs.bazField as any).$el.select(); | (this.$refs.bazField as any).$el.select(); | ||
}); | }); | ||
} | }</pre> | ||
Then add @keydown="onKeyDownFooCheckbox" define a method to set the keydown event listener on the checkbox and call it in mounted() callback: | Then add @keydown="onKeyDownFooCheckbox" define a method to set the keydown event listener on the checkbox and call it in mounted() callback: | ||
private initializeKeyDownEvents() { | |||
<pre>private initializeKeyDownEvents() { | |||
(this.$refs.fooCheckbox as any).$el.parentNode.removeEventListener('keydown', this.onKeyDownFooCheckbox); | (this.$refs.fooCheckbox as any).$el.parentNode.removeEventListener('keydown', this.onKeyDownFooCheckbox); | ||
(this.$refs.fooCheckbox as any).$el.parentNode.addEventListener('keydown', this.onKeyDownFooCheckbox); | (this.$refs.fooCheckbox as any).$el.parentNode.addEventListener('keydown', this.onKeyDownFooCheckbox); | ||
} | }</pre> | ||
<strong>Return to [[Programming Guide]]</strong> |
Latest revision as of 20:49, 3 October 2023
Use BoostrapVue's checkbox:
<b-form-checkbox v-model="isBar" >
Bar
</b-form-checkbox>
Confusingly, it can also be <b-checkbox> (src).
Tab navigation. See Tab Key Navigation section. To navigate away from the dropdown, define the keydown event handler:
private onKeyDownFooCheckbox(e: KeyboardEvent) { this.emulateTab( e, () => { (this.$refs.barField as any).$el.focus(); (this.$refs.barField as any).$el.select(); }, () => { (this.$refs.bazField as any).$el.focus(); (this.$refs.bazField as any).$el.select(); }); }
Then add @keydown="onKeyDownFooCheckbox" define a method to set the keydown event listener on the checkbox and call it in mounted() callback:
private initializeKeyDownEvents() { (this.$refs.fooCheckbox as any).$el.parentNode.removeEventListener('keydown', this.onKeyDownFooCheckbox); (this.$refs.fooCheckbox as any).$el.parentNode.addEventListener('keydown', this.onKeyDownFooCheckbox); }
Return to Programming Guide