Add blur and focus events to md-input

This commit is contained in:
John Ryan Camatog 2017-06-23 22:51:13 +08:00
parent e845b16a96
commit 6d2337fa4f
2 changed files with 29 additions and 2 deletions

View file

@ -114,6 +114,29 @@
</md-table-row>
</md-table-body>
</md-table>
<md-table slot="events">
<md-table-header>
<md-table-row>
<md-table-head>Name</md-table-head>
<md-table-head>Value</md-table-head>
<md-table-head>Description</md-table-head>
</md-table-row>
</md-table-header>
<md-table-body>
<md-table-row>
<md-table-cell>focus</md-table-cell>
<md-table-cell>Emits the <code>Event</code> object</md-table-cell>
<md-table-cell>Triggered when the user focuses the input</md-table-cell>
</md-table-row>
<md-table-row>
<md-table-cell>blur</md-table-cell>
<md-table-cell>Emits the <code>Event</code> object</md-table-cell>
<md-table-cell>Triggered when the user loses focus of the input</md-table-cell>
</md-table-row>
</md-table-body>
</md-table>
</api-table>
<api-table name="md-autocomplete">

View file

@ -68,14 +68,18 @@ export default {
this.parentContainer.inputLength = newValue ? newValue.length : 0;
});
},
onFocus() {
onFocus(event) {
if (this.parentContainer) {
this.parentContainer.isFocused = true;
}
this.$emit('focus', event);
},
onBlur() {
onBlur(event) {
this.parentContainer.isFocused = false;
this.setParentValue();
this.$emit('blur', event);
},
onInput() {
this.updateValues();