我有一个HTML列表,我想通过拖放更改他们的顺序,并在数据库中更新。但我不知道它是如何完成的。你能帮我吗?我使用HTML5sortable插件,但它不会在db。
中更新这是我的清单:
<ul class="sortable grid" >
<?php
$images = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
$i = 0;
foreach ($images as $value) {
?>
<li style='list-style-type: none' >
<img src='<?php echo $value->guid;?>' width='90' />
<a class='btn btn-danger' href='#' onclick='deletePic(<?php echo $i;?>)'>
<i class='icon-trash icon-white'></i>
Delete
</a>
</li>
<?php $i++; } ?>
</ul>
答案 0 :(得分:0)
在sortupdate事件处理程序
中编写ajax调用$('.sortable').sortable().bind('sortupdate', function() {
var menuId=[];
//store list id or some other unique field to identify your image into menuId variable
var request = $.ajax({
url: "script.php",
type: "POST",
data: { id : menuId },
dataType: "html"
});
});