HTML:
<div id="testVue">
<input id="test" v-model="testModel"/>
<button @click="clickMe()">Click me</button>
<button @click="showValue()">Show value</button>
</div>
Javascript
var testVue = new Vue({
el: '#testVue',
data: {
testModel: 'Hello Vue!'
},
methods: {
clickMe: function() {
$("#test").val("testing");
console.log(this.testModel);
},
showValue: function() {
console.log(this.testModel);
}
}
});
I totally understand I shouldn't do this in Vuejs $("#test").val("testing");, I should have do like this.testModel="testing";
But I can't understand why this basic binding doesn't work in Vuejs? I have quite a lot of HTML component that update the input box via jquery, for example Calendar, Autocomplete and Select2, all will update the Input box via non-vuejs way.
Any easy way to handle this?
this.testModel= 'testing';this.testModel='testing';