ho diversi elementi trascinabiliHTML5 evento dragend sparare immediatamente
<div Class="question-item" draggable="true">Box 1: Milk was a bad choice.</div>
<div class="question-item" draggable="true">Box 2: I'm Ron Burgundy?</div>
<div class="question-item" draggable="true">Box 3: You ate the entire wheel of cheese? </div>
<div class="question-item" draggable="true">Box 4: Scotch scotch scotch</div>
E ho i seguenti gestori di eventi:
var $questionItems = $('.question-item');
$questionItems
.on('dragstart', startDrag)
.on('dragend', removeDropSpaces)
.on('dragenter', toggleDropStyles)
.on('dragleave', toggleDropStyles);
function startDrag(e){
console.log('dragging...');
addDropSpaces();
e.stopPropagation();
}
function toggleDropStyles(){
$(this).toggleClass('drag-over');
console.log(this);
}
function addDropSpaces(){
$questionItems.after('<div class="empty-drop-target"></div>');
}
function removeDropSpaces(){
console.log("dragend");
$('.empty-drop-target').remove()
}
perché funziona solo per il primo trascinabile. Se trascino dire l'ultimo trascinamento, l'evento di trascinamento viene immediatamente attivato. (Non voglio usare jQuery UI btw)
Non ha senso per me - sembra un bug.
Sono su Chrome v 30 su OSX.
Ecco un link al JSFiddle: http://jsfiddle.net/joergd/zGSpP/17/
(Edit: questo è ripetizione del seguente domanda: dragend, dragenter, and dragleave firing off immediately when I drag - ma credo che il manifesto originale andava bene ad andare con jQuery UI, mentre io voglio che sia HTML5 nativo)