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

查看:79
本文介绍了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?

推荐答案

来自丢弃事件文档:

当 接受的可拖动对象被移到" (在此范围内) 可滴下的.在回调中,$(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. 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天全站免登陆