2

I'm using jQuery to create a droppable element - this appears to work fine, as the element gets the class ui-droppable.

I've set it up like this:

        $('#trashcan').droppable({
            drop: function( event, ui ) {
                alert('Dropped');
            }
        });

where #trashcan is an image.

Later, in response to a user action, I set up some draggables. These are table rows, and I set them up like this ('element' is just the created table row):

    $(element).draggable({
                revert: false, 
                helper: 'clone', 
                intersect: 'pointer',
                stop: function() {
                    alert('dropped');
                }});

Afterwards, they look like this:

    <tr class="ui-draggable">
    <td>First</td>
    <td>Name</td>
</tr>

So it all looks like it's set up ok. However, when I drag a table row over the trashcan, I get the 'dropped' from the draggable code, but not from the droppable. So the draggable has been dragged, but the droppable hasn't recognised it.

I'm not sure what to check for here. Is there any reason why it wouldn't work on table rows, for instance? I've checked things like z-index, and that doesn't appear to be the issue. Do I have to do something special to connect the draggable and droppable after the draggables are created (i.e. something that gets done when the droppable is created, which I need to re-do because the draggables are created later)?

4

0 に答える 0