【问题标题】:JQuery draggable droppable clone events on dragged object拖动对象上的 JQuery 可拖放可拖放克隆事件
【发布时间】:2016-01-01 11:48:47
【问题描述】:

我已成功拖动对象,但这些对象在克隆到新区域后不会保留在拖放之前附加到它们的鼠标事件。

instance.find('.gt-playlist-content').find("div[class*=gt_draggable]:not(.ui-draggable)").draggable({
        connectToSortable: ".gt_sortable",
        helper: "clone",
        revert: "invalid",
        start: function (event, ui) {
            var _item = jQuery(ui.helper); 

        }
    });


jQuery("#main .gt-playlist-content").droppable({
        tolerance: "touch",
        drop: function(event, ui) {
           //console.log(jQuery(ui.draggable));

       }
    }); 

有没有办法像使用 jQuery 一样克隆事件?

$(elem).clone(true);

编辑:

实际上我在这里找到了我的答案 如何克隆助手jquery-ui-draggable-helper-function-for-clonetrue-true-only-clones-once

虽然这个克隆插件实例数据我不想要。

【问题讨论】:

    标签: jquery draggable droppable


    【解决方案1】:

    给一个类拖动元素。而且,

    $('body').on('click','.theClass',function(){
    
        //Your codes
    });
    

    此点击事件适用于动态添加的元素。

    【讨论】:

    • 不,这是不可接受的,它不仅仅是点击,项目应该与数据和事件一起克隆。
    最近更新 更多