我的代码工作正常..但是我想在进行任何更改后立即将订单保存在第二列的Mysql中...我可以做的PHP编程,只是不知道如何将更改发送到php文件
查看我的代码(完整代码位于http://jsfiddle.net/helpinspireme/wMnsa/中)
<ul id="unassigned_list" class="connected_sortable">
<li class="ui-state-default"><div class="draggable_area">Item 1</div><div class="click_area">→</div><div class="cl"></div></li>
<li class="ui-state-default"><div class="draggable_area">Item 2</div><div class="click_area">→</div><div class="cl"></div></li>
</ul>
<ul id="recipients_list" class="connected_sortable">
<li class="ui-state-highlight"><div class="draggable_area">Item 3</div><div class="click_area">←</div><div class="cl"></div></li>
<li class="ui-state-highlight"><div class="draggable_area">Item 4</div><div class="click_area">←</div><div class="cl"></div></li>
</ul>
<script>
$("#unassigned_list, #recipients_list").sortable({
connectWith: ".connected_sortable",
items: "li",
handle: ".draggable_area",
stop: function(event, ui) {
updateLi(ui.item);
}
}).disableSelection().on("click", ".click_area", function() {
// First figure out which list the clicked element is NOT in...
var otherUL = $("#unassigned_list, #recipients_list").not($(this).closest("ul"));
var li = $(this).closest("li");
// Move the li to the other list. prependTo() can also be used instead of appendTo().
li.detach().appendTo(otherUL);
// Finally, switch the class on the li, and change the arrow's direction.
updateLi(li);
});
function updateLi(li) {
var clickArea = li.find(".click_area");
if (li.closest("ul").is("#recipients_list")) {
li.removeClass("ui-state-default").addClass("ui-state-highlight");
clickArea.html('←');
} else {
li.removeClass("ui-state-highlight").addClass("ui-state-default");
clickArea.html('→');
}
}
</script>
答案 0 :(得分:0)
您可以通过将id
添加到元素并将下面的代码添加到sortable
来实现:
update: function() {
var order = $(this).sortable('toArray');
alert(order);
}