简体   繁体   English

jQuery Ui拖放

[英]Jquery Ui drag and drop

I am dragging my elements from left nav to a droppable area using jquery UI,what should i do if i have to remove dragged elements from droppable area? 我正在使用jquery UI将元素从左侧导航拖动到可放置区域,如果我必须从可放置区域中删除被拖动的元素该怎么办? The simple functionality that I am expecting is that when it is dragged out of the container it should be deleted. 我期望的简单功能是,将其从容器中拖出时应将其删除。 It should not snap back to the container. 它不应卡回到容器中。 here is my code: 这是我的代码:

$(document).ready(function() {
$(".txtI").draggable({
    appendTo: "body",
    helper: "clone"
});

$("#phone").droppable({
    activeClass: "ui-state-default",
    hoverClass: "ui-state-hover",
    accept: ":not(.ui-sortable-helper)",
    drop: function(event, ui) {
        $(this).find(".placeholder").remove();
        ui.draggable.clone().removeClass("txtI").addClass("txt2").appendTo(this);
    }
}).sortable({
    items: "div",
    sort: function() {
        $(this).removeClass("ui-state-default");
    }
});

}); });

Thanks for your inputs. 感谢您的投入。 This is achieved by a simple line: 这是通过一条简单的代码实现的:

ui.draggable.remove(); ui.draggable.remove();

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

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