2014-06-16 2 views
0

다음 HTML을 가지고 있으며 끌어서 놓기 이벤트에 관련된 요소의 DOM 요소를 가져오고 싶습니다. 또한 디버거를 사용하여 이것을 어떻게 파악할 수 있는지 말해 줄 수 있다면 더 좋을 것입니다!검도 UI 드롭 이벤트 중 요소의 ID를 얻는 방법은 무엇입니까?

<div class="dragArea" id="choice1">proud</div> 
<div class="dragArea" id="choice2">strong</div> 
<div class="dragArea" id="choice3">merry</div> 
<div class="dragArea" id="choice4">friendly</div> 
<div class="dropArea k-header" id="gap1">Drop here</div> 
<div class="dropArea k-header" id="gap2">Drop here</div> 
<div class="dropArea k-header" id="gap3">Drop here</div> 
<div class="dropArea k-header" id="gap4">Drop here</div> 
<script>   
    $(".dragArea").kendoDraggable({ 
     group: "choicesGroup", 
     hint: function (element) { 
      return element.clone(); 
     } 
    }); 
    $(".dropArea").kendoDropTarget({ group: "choicesGroup", drop: onDrop }); 

    function onDrop(e) { 
     // How do i get the id of the elements involved in the drag and drop event? 

    } 
    </script> 
+1

는 F12을 사용하여 디버거를 열어'onDrop() '함수의 첫 번째 줄에 휴식을 놓고'e' 변수 들여다 : 여기

코드이다. 특히'draggable' 속성을 찾으십시오. 드래그 할 수있는 요소는 요소의 복제본이므로 HTML 내부에 ID가 있습니다. – Brett

답변

1
function onDrop(e) { 
    // Get the id of the elements involved in the drag and drop event 
     var source = $(e.draggable.element).attr('id'); 
     var target = e.dropTarget.attr('id'); 
}  
관련 문제