我有一个是通过AJAX填充列表。这个列表我可以添加和删除通过AJAX项目,并对其进行排序。我有两个问题吧。
I have a list that is populated via ajax. This list I can add and delete items via ajax and also sort them. I have two issues with it.
第一个是在这里,它仍然没有得到解决:jQuery (排序列表之后的是来自数据库的项目数量不会更新,直到我刷新)动态Drag'n降不更新订单
The first one is here and it's still unresolved: jQuery Dynamic Drag'n Drop doesn't update order (after sorting the list the number of the items that come from the database won't update until I refresh)
第二个是更差。当我通过AJAX更新我的名单上的内容(比如我添加了一个新项目),可排序的功能停止工作,直到我重新加载页面。看来.live不会与排序工作,我的想法与这一个。我会添加一些我的code:
The second one is worse. After I update the contents on my list via ajax (say I add a new item), the sortable function stops working until I reload the page. It seems .live won't work with sortable and I'm out of ideas with this one. I'll add some of my code:
我的列表是这样的:
<ul id="listaruta">
<li> ... </li>
</ul>
我的分拣物品脚本:
My script for sorting items:
$(function() {
$("ul#listaruta").sortable({
opacity: 0.6,
cursor: 'move',
update: function() {
var order = $(this).sortable("serialize") + '&action=updateRecordsListings';
$.post("/plugins/drag/updateDB.php", order);
}
});
});
我使用的是本作的排序功能: HTTP:// WWW .webresourcesdepot.com /可湿性粉剂内容/上传/文件/ jquerydragdrop /
搜索了很多经过我发现这是我的答案:的 jQuery的生活和排序
After searching a lot more I found this to be my answer: jQuery live and sortable
这是我加入到我的code,使其工作:
This is what I added to my code to make it work:
$(document).ajaxSuccess(function() {
$("ul#listaruta").sortable({
opacity: 0.6,
cursor: 'move',
update: function() {
var order = $(this).sortable("serialize") + '&action=updateRecordsListings';
$.post("/plugins/drag/updateDB.php", order);
}
});
});