mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-05-17 19:51:06 +00:00
prevent parent forms from submitting when adding chips #383
This commit is contained in:
parent
d718749396
commit
4bbe83b6ad
4 changed files with 20 additions and 13 deletions
|
|
@ -18,8 +18,8 @@
|
|||
:name="mdInputName"
|
||||
:disabled="disabled"
|
||||
@keydown.native.delete="deleteLastChip"
|
||||
@keydown.native.enter="selectChip"
|
||||
@keydown.native.186="selectChip"
|
||||
@keydown.native.prevent.enter="addChip"
|
||||
@keydown.native.prevent.186="addChip"
|
||||
tabindex="0"
|
||||
ref="input">
|
||||
</md-input>
|
||||
|
|
@ -77,7 +77,7 @@
|
|||
this.$refs.input.$el.focus();
|
||||
});
|
||||
},
|
||||
selectChip() {
|
||||
addChip() {
|
||||
if (this.currentChip && this.selectedChips.length < this.mdMax) {
|
||||
const value = this.currentChip.trim();
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ export default {
|
|||
placeholder: String
|
||||
},
|
||||
watch: {
|
||||
value() {
|
||||
this.setParentValue(this.$el.value);
|
||||
this.onInput();
|
||||
value(value) {
|
||||
this.setParentValue(value);
|
||||
this.updateValues(value);
|
||||
},
|
||||
disabled() {
|
||||
this.setParentDisabled();
|
||||
|
|
@ -41,18 +41,25 @@ export default {
|
|||
setParentPlaceholder() {
|
||||
this.parentContainer.hasPlaceholder = !!this.placeholder;
|
||||
},
|
||||
updateValues(value) {
|
||||
const newValue = value || this.$el.value || this.value;
|
||||
|
||||
this.setParentValue(newValue);
|
||||
this.parentContainer.inputLength = newValue ? newValue.length : 0;
|
||||
},
|
||||
onFocus() {
|
||||
this.parentContainer.isFocused = true;
|
||||
if (this.parentContainer) {
|
||||
this.parentContainer.isFocused = true;
|
||||
}
|
||||
},
|
||||
onBlur() {
|
||||
this.parentContainer.isFocused = false;
|
||||
this.setParentValue();
|
||||
},
|
||||
onInput() {
|
||||
this.setParentValue(this.value);
|
||||
this.parentContainer.inputLength = this.value ? this.value.length : 0;
|
||||
this.$emit('change', this.value);
|
||||
this.$emit('input', this.value);
|
||||
this.updateValues();
|
||||
this.$emit('change', this.$el.value);
|
||||
this.$emit('input', this.$el.value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
this.setParentRequired();
|
||||
this.setParentPlaceholder();
|
||||
this.handleMaxLength();
|
||||
this.onInput();
|
||||
this.updateValues();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
this.setParentRequired();
|
||||
this.setParentPlaceholder();
|
||||
this.handleMaxLength();
|
||||
this.onInput();
|
||||
this.updateValues();
|
||||
|
||||
if (!this.$el.getAttribute('rows')) {
|
||||
this.$el.setAttribute('rows', '1');
|
||||
|
|
|
|||
Loading…
Reference in a new issue