2012-01-20 58 views
0

我使用jQuery UI的1.7.2非常久遠的jQuery 1.3.2從jQuery UI的兩倍存在的丟棄事件

以下腳本導致被觸發兩次降事件。我嘗試了很多的時間,但不能弄清楚爲什麼? becouse您使用dropable和排序上相同的選擇$( 「列」)

任何建議,爲了解決這個問題

$("document").ready(function() { 

    $(".draggable").draggable({ 
     revert: "invalid", 
     helper: "clone", 
     connectToSortable: ".column" 
    }); 

    $(".column").droppable({ 
     accept: ".draggable", 
     drop: function (event, ui) { 
      debugger; 
      var ordinalNo = 1; 
      $(".column .contentObject").each(function() { 
       ordinalNo = ordinalNo + 1; 
      }); 

      var objectId = guidGenerator() + '_' + ordinalNo; 
      var objectType; 
      var contentObjContent = "<div id=\"" + objectId + "\" ><h2>[<span class=\"ordinal\"></span>] "; 

      if (event.srcElement.id === "tableobj") { 
       objectType = tableSource; 
      } 
      else if (event.srcElement.id === "chartobj") { 
       objectType = chartSource; 
      } 
      else if (event.srcElement.id === "textobj") { 
       objectType = textSource; 
      } 

      $.ajax({ 
       url: "/ContentBuilder/ContentObject", 
       data: { 
        viewObjectId: objectId, 
        contentObjectId: null, 
        contentObjectTypeId: objectType, 
        contentObjSourceId: null, 
        ordinal: ordinalNo 
       }, 
       type: "POST", 
       success: function (data) { 
        contentObjContent = data; 
       } 
      }); 
     } 
    }); 
    $(".column").sortable({ 
     connectWith: '.column', 
     handle: 'h2', 
     cursor: 'move', 
     placeholder: 'placeholder', 
     forcePlaceholderSize: true, 
     opacity: 0.4, 
     update: function (event, ui) { 
      changeOrdinal(); 
      if (event.srcElement.id.length <= 0) { 
       updateObjectOrdinals(); 
      } 
     } 
    }).disableSelection(); 

    $(".tablecolumn").sortable({ 
     connectWith: '.tablecolumn', 
     handle: 'h2', 
     cursor: 'move', 
     placeholder: 'placeholder', 
     forcePlaceholderSize: true, 
     opacity: 0.4, 
     update: function (event, ui) { 
      changeColumnOrdinal(); 
     } 
    }).disableSelection(); 
}); 

回答

1

。我認爲兩者都會引發下降。

+0

那麼我該如何解決這個問題。我希望項目是可排序和可拖動的。 – Saravanan

+0

也許你想用排序只...如果我記得正確的一個可排序的容器具有下降能力和排序項目的拖拽能力 – ggzone

+0

我會嘗試並在這裏發佈狀態。 – Saravanan