<?php
if ($_POST) {
$ids = $_POST["ids"];
for ($idx = 0; $idx < count($ids); $idx+=1) {
$id = $ids[$idx];
$ordinal = $idx;
//...
}
return;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>DragSort Example</title>
<meta charset="utf-8" />
<style type="text/css">
body { font-family:Arial; font-size:12pt; padding:20px; width: 800px; margin:20px auto; border:solid 1px black; }
h1 { font-size:16pt; }
h2 { font-size:13pt; }
ul { width:350px; list-style-type: none; margin:0px; padding:0px; }
li { float:left; padding:5px; width:100px; height:100px; }
li div { width:90px; height:50px; border:solid 1px black; background-color:#E0E0E0; text-align:center; padding-top:40px; }
.placeHolder div { background-color:white!important; border:dashed 1px gray !important; }
</style>
</head>
<body>
<div>
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<h1>jQuery List DragSort PHP Example</h1>
<a href="http://dragsort.codeplex.com/">Homepage</a><br/>
<br/>
<h2>Save list order with ajax:</h2>
<ul id="gallery">
<?php
$list = array("blue", "orange", "brown", "red", "yellow", "green", "black", "white", "purple");
for ($idx = 0; $idx < count($list); $idx+=1) {
echo "<li data-itemid='" . $idx . "'>";
echo "<div>" . $list[$idx] . "</div>";
echo "</li>";
}
?>
</ul>
<script type="text/javascript" src="jquery.dragsort-0.5.2.min.js"></script>
<script type="text/javascript">
$("#gallery").dragsort({ dragSelector: "div", dragEnd: saveOrder, placeHolderTemplate: "<li class='placeHolder'><div></div></li>" });
function saveOrder() {
var data = $("#gallery li").map(function() { return $(this).data("itemid"); }).get();
$.post("example.php", { "ids[]": data });
};
</script>
<div style="clear:both;"></div>
</div>
</body>
</html>
基于jquery实现的portal 拖拽实现布局调整
5星 · 超过95%的资源 需积分: 50 132 浏览量
2014-09-23
16:01:51
上传
评论
收藏 12KB ZIP 举报
linyangyang
- 粉丝: 1
- 资源: 7
最新资源
- mmqrcode1714153659780.png
- Screenshot_2024-04-27-06-08-58-486_com.baidu.xin.aiqicha.jpg
- 基于Javaweb+Tomcat+MySQL的大学生公寓管理系统+sql文件.zip
- 实训作业基于javaweb的订单管理系统源码+数据库+实训报告.zip
- 多机调度问题贪心算法基于最小堆和贪心算法求解多机调度问题.zip
- 基于同态加密技术的匿名电子投票系统源码.zip
- Pyqt5项目框架-PyQt项目开发实践
- 基于C通过MQTT的智能农业大棚管理系统(本科毕业设计)
- python+CNN的网络入侵检测算法源码.zip
- js 实现记住密码功能 js.cookie.min.js
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈