如何在自定义帮助器中重新实现jQuery的默认帮助器

我正在创建一个自定义拖动助手(在jQuery中):

$('.dragme', element).draggable({ appendTo: 'body', helper : custom_drag_helper, opacity : 0.5 }); 

我这样做是因为我想有时克隆并且有时会执行默认function,即拖动原始元素。

 function custom_drag_helper() { if (/*criteria on when to move instead of clone */) { return $(this); /* this is what helper: 'original' seems to do */ } else { clone = $(this).clone(); /* this is what helper: 'clone' does */ return clone; } } 

但我无法使用原始function。 return clone()工作正常,但返回$(this)没有任何乐趣。

好的,当输入这个问题时,我做了更多的潜水源并发现了这条小线:

 if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position"))) this.element[0].style.position = 'relative'; 

我在尝试解决这个问题的那一天没有找到。 添加this.style.position = 'relative'; 我上面的代码修复了问题!