jQuery Droppable,让元素被删除 [英] jQuery Droppable, get the element dropped

查看:22
本文介绍了jQuery Droppable,让元素被删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个小问题,希望有一个简单的答案,我正在使用 jQuery 可拖动和可放置将项目放入停靠栏.使用以下代码进行放置.

A small question hopefully with a simple answer, I am using jQuery draggable and droppable to place items into a dock. Using the below code for the drop.

$("#dock").droppable({
            drop: function(event, ui) {
                //Do something to the element dropped?!?
            }
        });

但是我无法找到一种方法来获取实际删除的元素,所以我可以做点什么.这可能吗?

However I couldn't find a way to get what element was actually dropped, so I can do something do it. Is this possible?

推荐答案

来自 drop 事件文档:

这个事件在接受的可拖动对象被拖放到上方"(在承受范围内)这个可丢弃.在回调中,$(this)表示可放置的可拖动的被丢弃.而 ui.draggable 代表可拖动的.

This event is triggered when an accepted draggable is dropped 'over' (within the tolerance of) this droppable. In the callback, $(this) represents the droppable the draggable is dropped on. While ui.draggable represents the draggable.

所以:

$("#dock").droppable({
     drop: function(event, ui) {
               // do something with the dock
               $(this).doSomething();

               // do something with the draggable item
               $(ui.draggable).doSomething();
           }
});

这篇关于jQuery Droppable,让元素被删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆