Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Draggable containment issue, cannot drag elements outside parent div

I have a very simple image manager, like so:

<div id="container">

    <div id="draggable-images">
        <img class="images" src="image1.jpg" />
        <img class="images" src="image2.jpg" />
        <img class="images" src="image3.jpg" />
    </div>

    <div id="droppable-area>
    </div>

</div>

And jQuery to go with it:

        $( ".images" ).draggable({ containment: "#container" });
        $( "#droppable-area" ).droppable();

And this is the CSS:

#draggable-images {
    overflow:scroll;
    overflow-x:hidden;
}

.images {
    z-index:10000;
}

Images are draggable, but they won't come out of their parent div, no matter what the containment is set to (even tried to set it to window).

Does anyone know how to make it work, or why it doesn't work?

I've set z-index high to make sure that's not the issue. I also tried making #draggable-images div without scrollbar, it didn't work either.

Seems to work like a charm on jQuery's site, can't figure what I'm missing.

like image 267
CodeVirtuoso Avatar asked Nov 01 '25 10:11

CodeVirtuoso


1 Answers

$('images').draggable({ appendTo: 'body' });
like image 90
printminion Avatar answered Nov 04 '25 05:11

printminion



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!