jQuery可拖动+可拖放+可排序 [英] JQuery Draggable + Droppable + Sortable

查看:77
本文介绍了jQuery可拖动+可拖放+可排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定以前已经回答了这个问题,但是我找不到适合我情况的示例.我有可拖动的图像列表.我还具有一个div(id ="dropZone"),该div设置为可放置和可排序.我想在图像拖放到div上时触发一个函数,但是当排序后将东西放到div上时不触发.这是我尝试过的:

I'm sure this has been answered before but I can't find an example to fit my situation. I've got a list of images that are draggable. I've also got a div (id="dropZone") that is set to droppable and sortable. I'd like to fire a function when the images get dragged and dropped on the div, but not when things are dropped on the div from being sorted. Here's what I tried:

stop: function() { $('#dropZone').prepend('<img src"img.png" />'); }

这是我添加到可投放图片中的图片,但是即使将它们放在可投放图片之外也会触发.

This I added to the droppable images, however this will fire even when they are dropped outside the droppable.

drop: function() { $('#dropZone').prepend('<img src="img.png" />'); }

然后我尝试将其添加到我的droppable中,但这会在拖动图像并对其进行排序时将其添加到图像中.

Then I tried adding this to my droppable, but this adds the image both when it is dropped from being dragged, and sorted.

有人知道我需要做什么吗?

Anyone know what I need to do?

推荐答案

问题很模糊,但似乎您需要的是来自sortable的接收事件.

The question is vague but it seems like what you need is the receive event from sortable.

$( ".selector" ).sortable({
   receive: function(event, ui) { ... }
});

http://jqueryui.com/demos/sortable/#connect-lists

仅当从另一个连接的列表中收到一个项目时,才会发生此事件.

This event will occur only when an item is received from another connected list.

这篇关于jQuery可拖动+可拖放+可排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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