tartışmajQuery: Sondan ilk sıraya diziler nasıl ('serialize') tersine çevrilir?
jQuery: What to do with the list that sortable('serialize') returns? son onu ters nasıl başlar ilk, updateList.php? Id [] = 5 & kimliği [] = 4 & kimliği [] = 3 & kimliği [] = 2 & id [] = 1 & & action = güncelleme?
<ul>
<li id="oreder-5">5</li>
<li id="oreder-4">4</li>
<li id="oreder-3">3</li>
<li id="oreder-2">2</li>
<li id="oreder-1">1</li>
<ul>
Kodum:
$(document).ready(function(){
order=[];
$('#list ul').children('li').each(function(idx, elm) { order.push(elm.id.split('-')[1]) });
$.post('updateList.php', {'order[]': order, action: 'update'});
function slideout(){
setTimeout(function(){ $("#response").slideUp("slow", function() {}); }, 2000);
}
$("#response").hide();
$(function() {
$("#list ul").sortable({ opacity: 0.8, cursor: 'move', update: function() {
var order = $(this).sortable("serialize") + '&action=update';
$.post("updateList.php", order, function(theResponse){
$("#response").html(theResponse);
$("#response").slideDown('slow');
slideout();
});
}});
});
});
Teşekkürler, @ karim79! imleci ile ikinci jquery kısmı için iyi çalışır: 'move' etkisi, ancak için çalışmıyor = []; $ ('# liste ul'), çocuklar ('li') her biri (işlev (idx, elm) {order.push (elm.id.split ('-') [1])}); $ .post ('updateList.php', {'order []': sipariş, eylem: 'update'}); Bunun için de çözüm bulabilir misiniz? – Binyamin
Parlak! Bunun için teşekkürler! –