问题描述
我有一个长列表的应用程序经常更改,我需要该列表的项目可以拖动。
我一直在使用jQuery UI draggable插件,但是添加到400+列表项目很慢,并且每次新列表项都必须重新添加被添加。有没有人知道一个类似于jQuery UI draggable插件的插件,它使用jQuery 1.3的 .live()
事件?这将解决这两个问题。
Wojtek的解决方案对我来说是完美的。我清理了改变它的一点点,使它扩展jQuery ...
(function($){
$ .fn.liveDraggable = function(opts){
this.live(mouseover,function(){
if(!$(this).data(init)){
$(this).data(init,true).draggable(opts);
}
});
返回此;
};
} (jQuery的));
现在,而不是像:
$(选择器).draggable({OPTS});
...只需使用:
$(selector).liveDraggable({opts})
I have an application with a long list that changes frequently, and I need the items of that list to be draggable.
I've been using the jQuery UI draggable plugin, but it is slow to add to 400+ list items, and has to be re-added every time new list items are added.
Does anyone know of a plugin similar to the jQuery UI draggable plugin that uses jQuery 1.3's .live()
events? This would solve both problems.
Wojtek's solution worked perfectly for me. I wound up changing it a tad bit to make it extend jQuery...
(function ($) {
$.fn.liveDraggable = function (opts) {
this.live("mouseover", function() {
if (!$(this).data("init")) {
$(this).data("init", true).draggable(opts);
}
});
return this;
};
}(jQuery));
Now instead of calling it like:
$(selector).draggable({opts});
...just use:
$(selector).liveDraggable({opts})
这篇关于jQuery拖放使用Live事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!