Skip to content

Commit

Permalink
feat(md-input): publish DOM blur event
Browse files Browse the repository at this point in the history
support validateTrigger.blur
ref: https://www.danyow.net/aurelia-validation-alpha/
  • Loading branch information
Ullfis committed Aug 27, 2016
1 parent 1bb0a8e commit 547ddb3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/input/input.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<div class="input-field">
<!-- <content select="[md-prefix]"></content> -->
<slot></slot>
<input if.bind="mdTextArea === false" id="${controlId}" type.bind="mdType" step.bind="mdStep" ref="input" value.bind="mdValue" disabled.bind="mdDisabled" />
<textarea if.bind="mdTextArea === true" id="${controlId}" ref="input" value.bind="mdValue" class="materialize-textarea" disabled.bind="mdDisabled"></textarea>
<input if.bind="mdTextArea === false" id="${controlId}" type.bind="mdType" step.bind="mdStep" ref="input" value.bind="mdValue" disabled.bind="mdDisabled" blur.trigger="blur()" />
<textarea if.bind="mdTextArea === true" id="${controlId}" ref="input" value.bind="mdValue" class="materialize-textarea" disabled.bind="mdDisabled" blur.trigger="blur()"></textarea>
<label for="${controlId}" ref="label">${mdLabel}</label>
</div>
</template>
7 changes: 7 additions & 0 deletions src/input/input.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 { TaskQueue } from 'aurelia-task-queue';
Expand Down Expand Up @@ -62,6 +63,12 @@ export class MdInput {
this.updateService.update();
}
blur() {
// forward "blur" events to the custom element
const event = DOM.createCustomEvent('blur');
this.element.dispatchEvent(event);
}
mdValueChanged() {
this.updateService.update();
if (this.mdTextArea) {
Expand Down

0 comments on commit 547ddb3

Please sign in to comment.