Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.hide()/.show() and Droppable

I have a problem where the element calls .show() when the draggable triggers drag, does not let me drop into the droppable. How can I fix this?

$(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>
like image 964
tpae Avatar asked Feb 05 '26 22:02

tpae


1 Answers

In $(".draggable_folder").draggable, change drag: function(event, ui) to start: function(). This will make .folder visible and the droppable will become active. The final code for draggable:

$(".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>');
  }
});
like image 74
Gert Grenander Avatar answered Feb 07 '26 14:02

Gert Grenander



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!