Cómo sobre el uso retire , recibir y actualizar para capturar todos los cambios y enviarlos al servidor como una matriz?
Demostración: http://jsfiddle.net/r2d3/p3J8z/
$(function(){
/* Here we will store all data */
var myArguments = {};
function assembleData(object,arguments)
{
var data = $(object).sortable('toArray'); // Get array data
var step_id = $(object).attr("id"); // Get step_id and we will use it as property name
var arrayLength = data.length; // no need to explain
/* Create step_id property if it does not exist */
if(!arguments.hasOwnProperty(step_id))
{
arguments[step_id] = new Array();
}
/* Loop through all items */
for (var i = 0; i < arrayLength; i++)
{
var image_id = data[i];
/* push all image_id onto property step_id (which is an array) */
arguments[step_id].push(image_id);
}
return arguments;
}
/* Sort images */
$('.step').sortable({
connectWith: '.step',
items : ':not(.title)',
/* That's fired first */
start : function(event, ui) {
myArguments = {}; /* Reset the array*/
},
/* That's fired second */
remove : function(event, ui) {
/* Get array of items in the list where we removed the item */
myArguments = assembleData(this,myArguments);
},
/* That's fired thrird */
receive : function(event, ui) {
/* Get array of items where we added a new item */
myArguments = assembleData(this,myArguments);
},
update: function(e,ui) {
if (this === ui.item.parent()[0]) {
/* In case the change occures in the same container */
if (ui.sender == null) {
myArguments = assembleData(this,myArguments);
}
}
},
/* That's fired last */
stop : function(event, ui) {
/* Send JSON to the server */
$("#result").html("Send JSON to the server:<pre>"+JSON.stringify(myArguments)+"</pre>");
},
});
});
Aquí está la explicación completa de la solución: http://r2d2.cc/2014/07/22/jquery-sortable-connectwith-how-to-save-all-changes-to-the-database/
Esto no es realmente un error, solo lo vincula al evento incorrecto. –