2010-04-22 5 views
1

에 내가 jQuery를 프레임 워크에 프로토 타입 프레임 워크를 기반으로 다음과 같은 자바 스크립트 코드를 업데이 트하려는자바 스크립트 변환은 프로토 타입에서 jQuery를

$(function() { 
    $('.piece').draggable(
    { 
     evert: true 
    } 
); 

    $('.cell').droppable(
    { 
     /* But here, it's more difficult. Right? ;) 
     ... */ 
    } 
    }); 
}); 

아이디어가 있습니까? 코드의 일부는 환영합니다. 고마워.

+0

그것의 대부분은 유사하다. droppable 함수에는 Prototype과 같은 accept 속성이 있으며 onDrop은 "drop (event, ui)"(이벤트)이라고합니다. "drop"의 경우 $ (this)는 삭제 가능한 항목을 나타내고 "ui.draggable"은 드래그 가능한 요소 (또는 사용자가 호출하는 항목)입니다. 당신이 여기에서 성취하고자하는 것에 관해서는, 나는 잘 모르겠다 ... 당신은 드랍 가능한 객체의 HTML을 드롭 가능한 객체로 가져 가려고 하는가? – RussellUresti

+0

실제로, 그것은 트위터에 체스를하는 웹 응용 프로그램입니다. 다음은 프로젝트 저장소입니다. http://github.com/jsanders/twitchess – moshimoshi

답변

0

여기에 내가 가진 무엇 :

jQuery(document).ready(function(){ 
    $('.piece').draggable({ 
     revert: true 
     , scope: 'piece_and_cell' 
    }); 

    $('.cell').droppable({ 
     drop: function(event, ui) { 
      var cell = $(this); 
      cell.empty(); 
      var piece = ui.draggable.detach() 
      piece.css({top:null, left: null}).appendTo(cell); 
      piece.draggable({ 
       revert: true 
       , scope: 'piece_and_cell' 
      }) 
     } 
     , scope: 'piece_and_cell' 
    }); 
}); 
관련 문제