简体   繁体   English

jQuery:删除的div仅在第二次单击后才能排序

[英]JQuery: dropped divs are sortable only after second click

When I drop some divs into a sortable pane, I can grab the newly created divs only after the second time I click on them. 当我将一些div放到可排序的窗格中时,只有在第二次单击它们之后,才能抓取新创建的div。 I suppose this is a refresh-related issue, but I cannot figure out how to make it work. 我想这是与刷新有关的问题,但是我无法弄清楚如何使其工作。

Here is the jsfiddle: http://jsfiddle.net/DvE5Q/ And the code: 这是jsfiddle: http : //jsfiddle.net/DvE5Q/和代码:

$(".box").draggable({
   helper: 'clone'
});
$("#left").droppable({
    accept: '.box.out',
    drop: function (e, ui) {
        $(this).append('<div class="box"></div>');
        var droppedBox = $(this).children().last();
        $(droppedBox).html(ui.helper.html());
    }
});
$("#left").sortable();

Thanks for your help! 谢谢你的帮助!

I would use the attribute connectToSortable: '#left' 我将使用属性connectToSortable: '#left'

DEMO http://jsfiddle.net/DvE5Q/1/ 演示http://jsfiddle.net/DvE5Q/1/

$(".box").draggable({
   helper: 'clone',
   connectToSortable: '#left'
});

$("#left").droppable({
    accept: '.box.out',
    drop: function (e, ui) {

    }
});

$("#left").sortable();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM