jQuery Sortable Update Event只能调用一次吗? [英] Jquery Sortable Update Event can called only one time?
本文介绍了jQuery Sortable Update Event只能调用一次吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Jquery&进行类别更改Php.我没有问题.我的问题是,当调用update事件时,它返回2个结果.拖拉父母有1个结果,滴下父母有1个结果.我只想打电话给掉父母的身份证.这是我的脚本:
I'm trying to make category changes with Jquery & Php. I have no problem with it. My problem is, when the update event is called, it returning 2 results. 1 result for Dragged Parent, One result for Dropped Parent. I wanna call only dropped parent's id. Here is my script:
$("#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();
你能帮我吗?
推荐答案
例如,使用update
,stop
和receive
事件
$(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();
});
这篇关于jQuery Sortable Update Event只能调用一次吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文