Skip to content

Commit

Permalink
feat(md-switch): forward blur event
Browse files Browse the repository at this point in the history
  • Loading branch information
Ullfis committed Sep 5, 2016
1 parent ddacfbd commit 0eb63b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/switch/switch.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<require from="./switch.css"></require>
<label>
${mdLabelOff}
<input type="checkbox" ref="checkbox">
<input type="checkbox" ref="checkbox" blur.trigger="blur()">
<span class="lever"></span>
${mdLabelOn}
</label>
Expand Down
6 changes: 6 additions & 0 deletions src/switch/switch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { bindable, customElement } from 'aurelia-templating';
import { DOM } from 'aurelia-pal';
import { bindingMode } from 'aurelia-binding';
import { inject } from 'aurelia-dependency-injection';
import { getBooleanFromAttributeValue } from '../common/attributes';
Expand Down Expand Up @@ -34,6 +35,11 @@ export class MdSwitch {
this.mdChecked = this.checkbox.checked;
}

blur() {
const event = DOM.createCustomEvent('blur');
this.element.dispatchEvent(event);
}

mdCheckedChanged(newValue) {
if (this.checkbox) {
this.checkbox.checked = !!newValue;
Expand Down

0 comments on commit 0eb63b5

Please sign in to comment.