使用jQuery ui sortable插件获取项目的开始位置 [英] get the start position of an item using the jquery ui sortable plugin
本文介绍了使用jQuery ui sortable插件获取项目的开始位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用jQuery UI可排序插件,并且试图获取2条警报
I am using the jQuery UI sortable plugin and I am trying to get 2 alerts
我想要元素的凝视位置和元素的完成位置.
I want the staring position of the element and the finished position of the element.
$(function() {
$("#filterlist ul").sortable({ opacity: 0.6, cursor: 'move', update: function(event, ui) {
alert(ui.item.prevAll().length + 1);
}
});
});
在拖动项目后,我可以使用以下方法获取它的位置:-
I can get the position of the item after it has been dragged by using:-
ui.item.prevAll().length + 1
如何使用它来开始工作?
What do I use to get the position it started from?
推荐答案
使用start
事件并缓存"起始位置
Use the start
event and "cache" the starting position
var start;
$(function() {
$("#filterlist ul").sortable({
opacity: 0.6,
cursor: 'move',
start: function(event, ui) {
start = ui.item.prevAll().length + 1;
},
update: function(event, ui) {
alert(start + " -> " + (ui.item.prevAll().length + 1));
}
});
})
这篇关于使用jQuery ui sortable插件获取项目的开始位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文