我正在使用可排序的jquery ui。我想获得排序数组,以将其传递给放置事件时的处理文件。
我发现了一件有趣的事。http://jsfiddle.net/7Ny9h/
$(function() {
$( "#sortable" ).sortable();
$( "#sortable" ).disableSelection();
$( "#sortable li" ).droppable({
drop: function( ) {
var order = $("#sortable").sortable("serialize", {key:'order[]'});
$( "p" ).html( order );
}
});
});
[看到样本,如果我移动2号框,则框2将留在阵列之外。
也许我需要一种“ dropend”事件,因为似乎jQuery ui drop事件没有计算拖放的事件。
您也可以使用update
进行检测。
$( "#sortable" ).sortable({
update: function( ) {
// do stuff
}
});
我可以通过jQuery UI Sortable stop
事件解决问题。
$(function() {
$( "#sortable" ).sortable();
$( "#sortable" ).disableSelection();
$( "#sortable" ).sortable({
stop: function( ) {
var order = $("#sortable").sortable("serialize", {key:'order[]'});
$( "p" ).html( order );
}
});
});