我正在使用可排序的jquery插件整理照片。如果您有10批货,则分类工作正常。但是,当照片多于10张时,排序将无法正常进行。
我的照片
<div class="sortable">
<div id="rank-1" class="multibox file">
<div class="picture_delete"></div>
<img src="../../images/gallery/thumb/1.jpg" style="cursor: move;" class="picture_uploaded">
</div>
<div id="rank-2" class="multibox file">
<div class="picture_delete"></div>
<img src="../../images/gallery/thumb/2.jpg" style="cursor: move;" class="picture_uploaded">
</div>
<div id="rank-3" class="multibox file">
<div class="picture_delete"></div>
<img src="../../images/gallery/thumb/3.jpg" style="cursor: move;" class="picture_uploaded">
</div>
</div>
(从数据库中获取我的照片)
Ajax
$ (document).ready(function () {
$('.sortable').sortable();
$('.sortable').on('sortupdate', function (event,ui) {
var data = $(this).sortable('serialize');
var url = 'inc/sort-gallery.php';
$.post(url, {data:data}, function(response) {
})
})
});
这是我的sortable.php
parse_str($_POST['data'], $siralama);
$rank=$siralama['rank'];
foreach ($rank as $key => $id) {
$query = $db->prepare("UPDATE galeri SET sira = :sirasi WHERE id = :idsi");
$update = $query->execute(array(
"sirasi" => $key,
"idsi" => $id,
));
}
就像我告诉你的那样。对前10张照片进行平滑排序。它工作顺利。但是当照片超过10张时,排序会被破坏。