끌어서 놓기 응용 프로그램에서 작업하고 어떤 개체가 이벤트를 기반으로하는지 혼란스러워집니다. 내가 드래그를 초기화 예를 들어 내가 다시 드래그 통화 실행하고 그래서 자신의 위치를 추적 할 수있는 UI를 전달하는 기능을 설정 :jQuery UI 끌어서 놓기 개체 - ui, ui.helper와 this의 차이점
이jQuery('.drag').draggable({
helper : 'clone',
drag : function (event, ui) { test(ui.helper, ui, this);}
});
function test(helper, drag_ui, drag_this){
//check the type of each, and as expected each are objects
console.log('HLEPER TYPE: '+jQuery.type(cln_h));//object
console.log('UI TYPE: '+jQuery.type(cl));//object
console.log('THIS TYPE: '+jQuery.type(this_elem));//object
//lets try and get the top position of each
console.log('helper.position.top: '+helper.position.top);//undefined
console.log('drag_ui.position.top: '+drag_ui.position.top);//working
console.log('jQuery(drag_this).position.top: '+jQuery(drag_this).position.top);//undefined
//So, the ui parameter gives us a result, ui.helper nothing, and this nothing.
//However, if I get the position() of the helper and this first, then I get results.
//get pos first
helper_pos = helper.position();
console.log('helper_pos.top: '+helper_pos.top);//working
drag_this_pos = jQuery(drag_this).position();
console.log('drag_this_pos.top: '+drag_this_pos.top);//working, but different result
//So now i have some results, but the weird thing is that drag_this is different to ui, and ui.helper.
}
내가 원하는 것은 정상 위치를 알고하는 것입니다 경우 도우미 클론 나는 그것을 끌고있다. 내가 본 다른 사례는이 세 가지 중 하나를 사용합니다 : ui, ui.helper and this. 내가 알고 싶은 것은 :
- 그들 모두의 차이점은 무엇입니까? 그것들은 모든 대상이지만 다른 속성입니까?
- 이 시나리오에서 가장 좋은 방법은 무엇입니까?
조금만 배우면 좋겠다.
감사합니다.