2008-10-09 3 views
2

내가 (jQuery를에) 사용자 정의 드래그 도우미를 만드는거야에서 jQuery의 기본 도우미를 재 구현하는 방법 : 가끔 복제 할 때로는 기본 기능을하기 때문에사용자 지정 도우미

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

내가이 일을 해요 , 즉 원래 요소를 드래그하십시오.

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; 
    } 
} 

하지만 원래의 기능을 전혀 사용할 수 없습니다. 반환 클론() 잘 작동하지만 반환 $ (이) 기쁨을 제공합니다.

답변

5

좋아, 내가 좀 더 소스 다이빙을했고,이 작은 선 발견이 질문에 타이핑 할 때 :

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

나는이 문제를 해결하기 위해 노력 지출 하루에 찾을 수 없습니다. 위의 코드에 this.style.position = 'relative';을 추가하면 문제가 해결되었습니다!

관련 문제