2011-09-24 75 views
0

我在这里面临一个奇怪的问题。我已经有了一个简单的jquery drag-n-drop试用版,它很有用。但是,现在我想将代码从试用项目移到我现在正在工作的项目文件中。一切都是相同的,但我不能让丢弃事件被解雇。这实在是急了,请帮助... 我包括我的代码,以防万一......jQuery Drop事件不起作用

$('.image').draggable({ 
      cursor: 'move' 
     }); 

     // Put img resizable is to have the ghost 
     $('.image img').resizable({ 
      ghost: true, 
      stop: function (event, ui) { 
       var eid = $(this).parent().attr('id'); 
       alert(eid); 
       var wid = $(this).width(); 
       alert(wid); 
       var hei = $(this).height(); 
       alert(hei); 
       updateSize(eid, wid, hei); 
      } 
     }); 

     // Variable to hold drop options 
     var options = {}; 

     // Once image re-drop, update its position 
     options.drop = function (event, ui) { 
      // Check image id to check whether image exist or not 
      if (ui.draggable.attr('id').match(/_(\d+)$/) != null) { 
       var element = ui.draggable; 
       updatePosition(element); 
      } 
      else { 

       // Store the clone position 
       var leftPosition = ui.offset.left; 
       var topPosition = ui.offset.top; 
       alert('Left: ' + leftPosition + ' Top: ' + topPosition); 

       // Variable to generate new image id 
       var counter = new Date().valueOf(); 

       // Create the clone 
       //var element = ui.draggable.clone(); 

       // Assign new id for clone element 
       var oldID = ui.draggable.attr('id'); 
       alert('old id ' + oldID); 
       ui.draggable.attr('id', (oldID + '_' + counter)); 

       // Call CreateContainer 
       createContainer(ui.draggable, oldID, topPosition, leftPosition); 
      } 
     }; 
     $('#rightframe').droppable(options); 
+0

有包括你的jquery.js和jquery-ui.js – Rafay

+0

嗨,我包括: – shennyL

回答