在最后一次放下操作后(可放置的元素编号总是不同)我想显示例如提交按钮。
这是一个工作示例(相应部分):
$('.unsortedChoiceBox1 li').draggable({
appendTo: "body",
helper: "clone",
revert: true,
scope: "d1",
});
$( "#droppable1 ol" ).droppable({
scope: "d1",
activeClass: "ui-state-default",
hoverClass: "ui-state-hover",
accept: '.unsortedChoiceBox1 li',
drop: function( event, ui ) {
ui.draggable.draggable('option','revert',false);
ui.draggable.clone().appendTo(this);
ui.draggable.remove();
}
});
请给我一个想法:如何检测哪个可拖动元素是最后一个?
答案 0 :(得分:0)
这是代码。你需要在drop事件上计算drag element和increment counter
$('.unsortedChoiceBox1 li').draggable({
appendTo: "body",
helper: "clone",
revert: true,
scope: "d1",
});
var count = 0;
var drags = $('.unsortedChoiceBox1 li').size();
$("#droppable1 ol").droppable({
scope: "d1",
activeClass: "ui-state-default",
hoverClass: "ui-state-hover",
accept: '.unsortedChoiceBox1 li',
drop: function(event, ui) {
ui.draggable.draggable('option', 'revert', false);
ui.draggable.clone().appendTo(this);
ui.draggable.remove();
count++;
if (drags == count) {
alert('all elements are dropped');
//show submit button
}
}
});