1
我需要一些在jQuery中使用clone()
的帮助。如何用jQuery克隆touchevents?
所以,事情是这样的:我正在做某种拖动&下降&排序,将在触摸设备上工作。一切都很好,除了当我克隆一个元素时,事件不见了(拖动停止工作)。
的代码看起来像这样(在简体):
$('li', layers).each(function(){
this.addEventListener('touchend', function(e){
var cloned = $(this).clone(true, true); // no events are cloned at all!
cloned.insertBefore(this.helper);
}); //ontouchend
this.addEventListener('touchmove', function(e){
// do some stuff with this.helper
});
});
我该怎么办错了吗?
谢谢!
你也删除`touchend`原?如果是这样,你可以试试`this.insertBefore(...)`;它会自动移动。 – pimvdb 2011-08-17 11:17:41