Abh*_*ain 29 jquery jquery-ui-sortable
在下面的更新功能的代码,当一个项目从列表中移出被调用两次sortable1
到sortable2
.虽然我只需要调用一次该函数:
$("#sortable1 tbody, #sortable2 tbody").sortable({
connectWith: '.connectedSortable tbody',
helper: fixHelper,
handle : '.handle',
update : function () {
var order = $('#sortable1 tbody').sortable('serialize');
}
}).disableSelection();
Run Code Online (Sandbox Code Playgroud)
Ste*_*fan 58
答案来自:http://forum.jquery.com/topic/sortables-update-callback-and-connectwith
update: function(e,ui) {
if (this === ui.item.parent()[0]) {
//your code here
}
}
Run Code Online (Sandbox Code Playgroud)
use*_*ser 11
Stefan的答案很好,但是它没有提到另外一个难题,所以这里是 - 如果有人(像我一样)不能马上得到它.这应该使您可以在update()
函数中处理所有这些并且不必弄乱receive()
(只有在容器间运动发生时才会触发):
update: function(e,ui) {
if (this === ui.item.parent()[0]) {
if (ui.sender !== null) {
// the movement was from one container to another - do something to process it
// ui.sender will be the reference to original container
} else {
// the move was performed within the same container - do your "same container" stuff
}
}
}
Run Code Online (Sandbox Code Playgroud)
试试这个:
update: function(e,ui) {
if (!ui.sender) {
//your code here
}
}
Run Code Online (Sandbox Code Playgroud)
您应该使用接收事件(http://jqueryui.com/demos/sortable/#event-receive)。
在http://bugs.jqueryui.com/ticket/3178 的最底部查看分辨率。
我刚刚遇到了这个。这是 jQuery UI 中的一个错误,请参阅http://bugs.jqueryui.com/ticket/4872#comment:2
我发表评论是为了看看是否可以叫醒任何人,让他们知道何时会有修复。社区驱动发展的乐趣 :P
归档时间: |
|
查看次数: |
11815 次 |
最近记录: |