Jquery可排序更新事件只能调用一次?
我正在尝试使用Jquery和Php进行类别更改。我没有问题。我的问题是,当调用update事件时,它返回2个结果。1个结果用于拖动的父级,一个结果用于删除的父级。我只想打掉父母的id。这是我的脚本:Jquery可排序更新事件只能调用一次?,jquery,draggable,jquery-ui-sortable,Jquery,Draggable,Jquery Ui Sortable,我正在尝试使用Jquery和Php进行类别更改。我没有问题。我的问题是,当调用update事件时,它返回2个结果。1个结果用于拖动的父级,一个结果用于删除的父级。我只想打掉父母的id。这是我的脚本: $("#gallery ul").sortable({ connectWith: '.dropBox', opacity: 0.35, scroll: true, scrollSensitivity: 100, //handle: '.move',
$("#gallery ul").sortable({
connectWith: '.dropBox',
opacity: 0.35,
scroll: true,
scrollSensitivity: 100,
//handle: '.move',
helper: 'clone',
containment:'#gallery',
accept:'#gallery > .photo',
revert: true,
update: function(event, ui){
params = 'c=' + $(this).attr('id') + '&id=' + ui.item.attr('id');
$.ajax({
type: 'POST',
url: 'processData.php',
data: params,
error:function(){
alert("Error!");
},
success:function(data){
$("#serverResponse").html(data);
}
});
}
}).disableSelection();
你们能帮帮我吗?你们应该试着玩
可排序的不同事件
- 开始
- 分类
- 改变
- 前森林
- 停止
- 更新
- 接收
- 除去
- 结束
- 出去
- 激活
- 停用
我很肯定其中一个会是你的答案
来源:ui。发送者只存在于第二个回调中
$(".sortable").sortable({
connectWith: ".sortable",
update: function (evt, ui) {
// just ignore the second callback
if(ui.sender == null){
// call ajax here
}
},
receive: function (evt, ui) {
// called after the first 'update'
// and before the second 'update'
// ui.sender is always exists here
}
}).disableSelection();
例如,使用更新
、停止
和接收
事件
$(function() {
position_updated = false; //flag bit
$(".sortable").sortable({
connectWith: ".sortable",
update: function(event, ui) {
position_updated = !ui.sender; //if no sender, set sortWithin flag to true
},
stop: function(event, ui) {
if (position_updated) {
//code
position_updated = false;
}
},
receive: function(event, ui) {
// code
}
}).disableSelection();
});
只要这样做:
update: function(event, ui) {
if(ui.sender) {
// Your actual code
}
},