.hide()/。show()和Droppable

时间:2010-06-27 04:34:38

标签: jquery jquery-ui draggable droppable

我有一个问题,当拖动拖动时,元素调用.show(),不会让我掉进droppable。我该如何解决这个问题?

$(document).ready(function() {
$(".folder").droppable({
        greedy: true,
        drop: function(event, ui) {
            $(".folder").hide();
        },
        tolerance: 'touch'
    });

$(".folder").hide();
$(".draggable_folder").draggable({ 
    cursor: 'move',
    cursorAt: { top: 8, left: 0 },
    drag: function(event, ui) {
        $(".folder").show();
    },
    helper: function(event) {
        var subject = $(this).find('.message_subject').html();
        return $('<div class="ui-widget-header" style="max-width: 100px;">'+subject+'</div>');
    }
});
});

<ul>
    <li class="folder">{$folders[f_list].name}</a><div style="clear:both"></div></li>
</ul>
<table>
    <tr class="draggable_folder"><td>test</td></tr>
</table>

1 个答案:

答案 0 :(得分:2)

$(".draggable_folder").draggable中,将drag: function(event, ui)更改为start: function()。这将使.folder可见,并且droppable将变为活动状态。可拖动的最终代码:

$(".draggable_folder").draggable({ 
  cursor: 'move',
  cursorAt: { top: 8, left: 0 },
  start: function() {
    $(".folder").show();
  },
  helper: function(event) {
    var subject = $(this).find('.message_subject').html();
    return $('<div class="ui-widget-header" style="max-width: 100px;">'+subject+'</div>');
  }
});