jquery UI 에서 드래그 정렬 예시 분석

예시 참조http://jsfiddle.net/KyleMit/Geupm/2/  (이 역 은 FQ 가 있어 야 효 과 를 볼 수 있 습 니 다)
사실은 jquery UI 공식 카 트 드래그 에 예 를 추가 한 증강 판 으로 드래그 할 때 정렬 을 추가 한 것 입 니 다.
html 코드 입 니 다.
 
  

Products



T-Shirts


   

       

               
  • Lolcat Shirt

  •            
  • Cheezeburger Shirt

  •            
  • Buckit Shirt

  •        

   

Bags


   

       

               
  • Zebra Striped

  •            
  • Black Leather

  •            
  • Alligator Leather

  •        

   

Gadgets


   

       

               
  • iPhone

  •            
  • iPod

  •            
  • iPad

  •        

   




Shopping Cart


   

       

               
  1. Add your items here

  2.        

   



이것 은 js 코드 입 니 다. 주로 js 코드 에서 빨간색 코드 부분 에 드래그 해서 들 어 갈 때 정렬 할 수 있 도록 설정 되 어 있 습 니 다. 주황색 코드 부분 은 이해 가 안 되 고 쓸모 가 없 는 것 같 습 니 다.
 
  
$(function () {
    $("#catalog").accordion();
    $("#catalog li").draggable({
        appendTo: "body",
        helper: "clone",
        connectToSortable: "#cart ol"
    });
    $("#cart ol").sortable({
        items: "li:not(.placeholder)",
        connectWith: "li",
        sort: function () {
            $(this).removeClass("ui-state-default");
        },
        over: function () {
            //hides the placeholder when the item is over the sortable
            $(".placeholder").hide();
        },
        out: function () {
            if ($(this).children(":not(.placeholder)").length == 0) {
                //shows the placeholder again if there are no items in the list
                $(".placeholder").show();
            }
        }
    });
});

그리고 언급 할 만 한 것 은
. ui - state - default 는 끌 어 당 길 때 내 장 된 클래스 인 것 같 습 니 다. 이에 대응 하 는 것 은 ui - state - hover 등 이 끌 어 당 길 수 있 는 대상 이 끌 어 당 길 때 와 용기 에 끌 어 당 길 때의 효과 도 있 습 니 다. 본 고 는 코드 가 나타 나 지 않 았 습 니 다.
다음은 jQuery UI 에서 드래그 정렬 문제 에 대한 분석 입 니 다. 마음 에 드 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기