I have a vue component with separate events for click/dblclick. Single click (de)selects row, dblclick opens edit form.
<ul class="data_row" v-for="(row,index) in gridData" @dblclick="showEditForm(row,$event)" @click="rowSelect(row,$event)" >
Doing it like this, i get 3 events fired on double click. Two click events and lastly one dblclick. Since the click event fires first , is there a way (short of deferring click event for a fixed amount of ms) for stopping propagation of click event on double click ?
Fiddle here
As suggested in comments, You can simulate the dblclick event by setting up a timer for a certain period of time(say x).
See below code and working fiddle.
new Vue({ el: '#app', data: { result: [], delay: 700, clicks: 0, timer: null }, mounted: function() { console.log('mounted'); }, methods: { oneClick(event) { this.clicks++; if (this.clicks === 1) { this.timer = setTimeout( () => { this.result.push(event.type); this.clicks = 0 }, this.delay); } else { clearTimeout(this.timer); this.result.push('dblclick'); this.clicks = 0; } } } });
<div id="example-1"> <button v-on:dblclick="counter += 1, funcao()">Add 1</button> <p>The button above has been clicked {{ counter }} times.</p> </div>
var example1 = new Vue({ el: '#example-1', data: { counter: 0 }, methods: { funcao: function(){ alert("Sou uma funcao"); } } })
check out this working fiddle https://codepen.io/robertourias/pen/LxVNZX
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With