2010-07-11 82 views
0

由於某種原因,我得到'ui.size'未定義的錯誤。這裏是我的代碼:ui.size在draggable中不工作()jquery-ui

$('.canvas').draggable({ 
     containment: $('.canvas'), 
     refreshPositions: true, 
     drag: function(e, ui) { 
      area.css('border', 'none'); 
     }, 
     stop: function(event, ui){ 
      var pinpointHeight, pinpointWidth, pinpointTop, pinpointLeft; 
      var offset = $('.canvas').offset(); 

      for (var i = 0; i < image.pinpoints.length; i++) { 
       if(image.pinpoints[i].position == position){ 
        pinpointHeight = image.pinpoints[i].height; 
        pinpointWidth = image.pinpoints[i].width; 
       } 
      } 
      var offset2 = area.children('#inner').offset(); 
      myPinpoint = { 
       "top": offset2.top - offset.top-2, 
       "left": offset2.left - offset.left-2, 
       "width": ui.size.width, 
       "height": ui.size.height, 
       "position": position }; 
      $.fn.mapImage.updatePinpoint(image, myPinpoint, position, (offset2.left - offset.left-2), (offset2.top - offset.top-2 + pinpointHeight)); 
      //$.fn.pinpointImage.add(image, myPinpoint); 

     }    
    }); 

回答

1

從文檔UI/Draggableui對象只具有以下3個屬性:

  • ui.helper
  • ui.position
  • ui.offset

沒有ui.size。你可以做的是用

ui.helper.width() 
ui.helper.height()