M
M
MarEeeeeee2020-09-30 10:21:58
css
MarEeeeeee, 2020-09-30 10:21:58

How to bind the sending of a POST request to the dblckick event in Vue.js?

Code for my double click handler. At the same moment, I want the data about elem.fileName to be sent to the server and processed there

methods:{
        clickOnRow: function(event, elem){
          this.clicks++ 
          if(this.clicks === 1) {
            var self = this
            this.timer = setTimeout(function() {            
            console.log("одинарный");                 
              self.clicks = 0
            }, this.delay);
          } else{
             clearTimeout(this.timer);
             console.log("двойной");
             console.log(elem.fileName);
             this.currentElem = elem.fileName;
             this.$emit('current-elem',this.elem.fileName);
             this.clicks = 0;    
          }        	
        }
    }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Komarov, 2015-12-18
@BMO1337

HTML:

<div id="page-preloader">
  <div class="spinner"></div>
</div>

jQuery:
$(window).load(function() {
  $(".spinner").fadeOut("fast");
  $("#page-preloader").slideUp("slow");
}

W
WapSter, 2020-09-30
@wapster92

For example like this
<div class="element" @dblclick="sendPost"></div>

methods: {
      async sendPost() {
        const response = await fetch('url',{
          method: 'POST',
          headers: {
            'Content-Type': 'application/json'
          },
          body: JSON.stringify({'Тело запроса'})
        })
      }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question