mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-03-16 22:10:27 +00:00
Issue#544 (#674)
* chips autocomplete * criando autocomplete * base solida * fixing issue #544 * removing old files * reduced debounce time
This commit is contained in:
parent
1371d6c690
commit
4bcb6870ce
2 changed files with 32 additions and 2 deletions
|
|
@ -71,6 +71,12 @@
|
|||
<md-table-cell>Sets the type. Default <code>text</code></md-table-cell>
|
||||
</md-table-row>
|
||||
|
||||
<md-table-row>
|
||||
<md-table-cell>debounce</md-table-cell>
|
||||
<md-table-cell><code>Number</code></md-table-cell>
|
||||
<md-table-cell>Debounce the <code>change</code> and <code>input</code> events emission. Default <code>300</code>ms</md-table-cell>
|
||||
</md-table-row>
|
||||
|
||||
<md-table-row>
|
||||
<md-table-cell>disabled</md-table-cell>
|
||||
<md-table-cell><code>Boolean</code></md-table-cell>
|
||||
|
|
@ -115,6 +121,12 @@
|
|||
<md-table-cell>A required model object to bind the value.</md-table-cell>
|
||||
</md-table-row>
|
||||
|
||||
<md-table-row>
|
||||
<md-table-cell>debounce</md-table-cell>
|
||||
<md-table-cell><code>Number</code></md-table-cell>
|
||||
<md-table-cell>Debounce the <code>change</code> and <code>input</code> events emission. Default <code>300</code>ms</md-table-cell>
|
||||
</md-table-row>
|
||||
|
||||
<md-table-row>
|
||||
<md-table-cell>disabled</md-table-cell>
|
||||
<md-table-cell><code>Boolean</code></md-table-cell>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,21 @@
|
|||
export default {
|
||||
props: {
|
||||
value: [String, Number],
|
||||
debounce: {
|
||||
type: Number,
|
||||
default: 3E2
|
||||
},
|
||||
disabled: Boolean,
|
||||
required: Boolean,
|
||||
maxlength: [Number, String],
|
||||
name: String,
|
||||
placeholder: String
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
timeout: 0
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
value(value) {
|
||||
this.setParentValue(value);
|
||||
|
|
@ -29,6 +39,15 @@ export default {
|
|||
this.parentContainer.enableCounter = this.maxlength > 0;
|
||||
this.parentContainer.counterLength = this.maxlength;
|
||||
},
|
||||
lazyEventEmitter() {
|
||||
if (this.timeout) {
|
||||
window.clearTimeout(this.timeout);
|
||||
}
|
||||
this.timeout = window.setTimeout(() => {
|
||||
this.$emit('change', this.$el.value);
|
||||
this.$emit('input', this.$el.value);
|
||||
}, this.debounce);
|
||||
},
|
||||
setParentValue(value) {
|
||||
this.parentContainer.setValue(value || this.$el.value);
|
||||
},
|
||||
|
|
@ -58,8 +77,7 @@ export default {
|
|||
},
|
||||
onInput() {
|
||||
this.updateValues();
|
||||
this.$emit('change', this.$el.value);
|
||||
this.$emit('input', this.$el.value);
|
||||
this.lazyEventEmitter();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue