1 回答
TA贡献1817条经验 获得超6个赞
经过更多的挖掘,我找到了解决方案,而不是使用 jQuery 函数,我必须使用 SortableJS 的内置toArray()函数来获取“#sortable-cards”的更新列表。该toArray()函数用于data-id代替id您的 div、li 等。这里有更多关于此的信息。
JavaScript
$(document).ready(function(){
$("#sortable-cards").sortable({
animation: 350,
easing: "cubic-bezier(1, 0, 0, 1)",
store: {
set: function (sortable) {
var order = sortable.toArray();
console.log(order);
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: '{{route('manage.orderCategories')}}',
type: 'POST',
data: order,
success: function(data){
console.log('Success');
},
error: function(){
console.log('Fail');
}
});
}
}
});
});
- 1 回答
- 0 关注
- 120 浏览
添加回答
举报