我以前没有使用过jquerysortable。但你能做的是在监听拖动事件的函数中,我假设它是:
$("table #sort").sortable({
receive: function(event, ui) {
var line = ui.item.closest('td').text();
var new_status = line.split('\n')[0];
console.log(new_status);
var objid = ui.item.find('label').html()
console.log(objid);
}
});
然后可以在其中添加一个ajax函数,如:
$("table #sort").sortable({
receive: function(event, ui) {
var line = ui.item.closest('td').text();
var new_status = line.split('\n')[0];
console.log(new_status);
var objid = ui.item.find('label').html()
console.log(objid);
$.ajax({
url: 'new/status', //create a route that points to controller to save new status
data: {objid, new_status},
method: 'post',
success: function(data){
alert("success")
},
error: function(data){
alert("fail")
}
});
}
});