问题描述
我希望能够将图像拖动到两个容器(容器1和容器2)中的一个。从那里,这取决于容器的图像降至,我想更新容器数据库调用(或者只是我的一个表更新一行)。
I'd like to be able to drag an image into one of two containers (container 1 and container 2). From there, depending on which container the image was dropped to, I'd like to update that container with a database call (or just update a row in one of my tables).
我想使用 http://jqueryui.com/demos/droppable/ 以做到这一点,但我不知道如何处理请求,以及如何让每个容器监听事件处理程序(下降的图像)。
I'd like to use http://jqueryui.com/demos/droppable/ to achieve this, but I'm not sure how to process the request, and how to get each container to listen for an event handler (dropping of the image).
我在下面画一个非常糟糕的图来解释一下我的意思是:
I've drawn a really bad diagram below to explain what I mean:
推荐答案
在投掷的演示正说明如何做到这样的事情。
The droppable demo shows exactly how to do this sort of thing.
$(function() {
$( "#draggable" ).draggable();
$( "#droppable" ).droppable({
drop: function( event, ui ) {
$( this )
.addClass( "ui-state-highlight" )
.find( "p" )
.html( "Dropped!" );
}
});
});
我自己很基本的演示→ (更新)
这篇关于我怎样才能删除一个图像到容器中,然后更新容器基于什么降至呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!