嗯,我有这个代码用于拖放,但我想这样做,当我重新加载页面时,它保存拖动项目的位置。我考虑过使用AJAX,但我真的不知道如何将AJAX代码放在函数中。
$(document).ready(function(){
$( ".draggable" ).draggable({
cancel: "a.ui-icon", // clicking an icon won't initiate dragging
containment: "document",
revert: "invalid",
cursor: "move",
scope: "drop",
});
$(".draggable").bind("dragstop", function (e, ui)
{
console.log(ui.position.top);
console.log(ui.position.left);
});
$(".drop").droppable({ accept: ".draggable", scope: "drop"});
$("#origin").droppable({ accept: ".draggable", scope: "drop"});
$(".drop").sortable();
$("#origin").sortable({connectWith: ".drop"});
$(".drop").sortable({connectWith: "#origin"});
} );