jQuery 拖放图像的顺序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3923600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
drag and drop ordering of images
提问by Roscoe
I have 5 images that go into a banner on my homepage. These images are stored in the database but what I would like the user to do is drag and drop them so they retain some order.
我有 5 张图片进入我主页上的横幅。这些图像存储在数据库中,但我希望用户做的是拖放它们,以便它们保留一些顺序。
What I need to do is a
我需要做的是
(i) drag and drop the images in a container div so left if position 1 and right is position 5.
(i) 如果位置 1 和右侧是位置 5,则将图像拖放到容器 div 中。
(ii) on sumbit save the position as a field in the database.
(ii) 在 sumbit 上将位置保存为数据库中的字段。
Some pointers would be nice, probably use jquery if possible.
一些指针会很好,如果可能的话可能使用 jquery。
Thanks.
谢谢。
回答by Tatu Ulmanen
Use jQuery UI's Sortableand it's associated methods to do a AJAX call to your server on state change.
使用jQuery UI 的 Sortable及其相关方法在状态更改时对服务器进行 AJAX 调用。