W
W
willgood2020-08-26 11:29:29
JavaScript
willgood, 2020-08-26 11:29:29

vuejs. How to implement event handling on input?

Code snippet that works in the browser but doesn't work in browsers on mobile devices:

<div id="example">
  
 <input type="text" v-model="addressModel" v-on:keyup="getData()" placeholder="">  
</div>

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

<script>
var example = new Vue({
  el: '#example',
  data: {
    addressModel: ''
  },  
  methods: {
    getData() {
     console.log(this.addressModel);
      //send request to api
    }
  }
})

</script>


How to force this code on mobile devices (we send a request to api when changing the input).

https://codepen.io/Gur/pen/oNxZaKm

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
willgood, 2020-08-26
@willgood

I did this (added watcher):

watch:{
        addressModel: function(){            
            this.getData();
        }
 }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question