In an html I have a v-model='code'
with an attribute v-on:change='consultar()'
which at the time of typing the code and tabular (for example, (is one of many ways to make the change)), he goes to that method and I list the data in a form, right there!
'The problem'
In the method 'consultar'
valid that when the form is empty and when not run the post, the problem is that to validate that the field is empty or not, I should always make a change and the idea is that as long as I do the backspace
and know that it's empty I clean the form without having to make the change.
Code
HTML
<input type="text" v-model='code' v-on:change='consultar()' placeholder="ingrese codígo">
VueJS
new Vue({
el: '#content',
data: {
code: '',
datos: {
name: '',
etc..
} // Aqui van todos los parametros para el formulario
},
methods: {
consultar: function () {
if (this.code == '') {
this.datos = {},
} else {
// ejecutar el post
}
},
},
})
I appreciate the interest.