views:

365

answers:

3

I have a draggable object inside of an accordion widget. When dragging it, it's constrained its parent, the accordion element. I've tried to use the 'containment' option with no success.

I have tried this with FireFox 3.5.5 and Chromium 4.

Is there a way to solve it?

Thanks

+1  A: 

Have you tried using the containment value of 'document':

$("#draggable1").draggable({ containment: 'document' });

Here's an example I was able to drag outside the accordion:

<div id="accordion">
    <h3><a href="#">Section 1</a></h3>
    <div id="draggable1">
    <p>
        Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
  ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
  amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
  odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
    </p>
    </div>
    <h3><a href="#">Section 2</a></h3>
    <div>
        <p>
  Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
  purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
  velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
  suscipit faucibus urna.
  </p>
 </div>
</div>

<script type="text/javascript">
$(function() {
 $("#accordion").accordion();
 $("#draggable1").draggable({ containment: 'document' });
});
</script>
CAbbott
I appreciate your help but I'm afraid I haven't made myself clear. The draggable object is not an accordion element itself but it's inside one of them.
Artur Soler
+2  A: 

My answer applies to sortables, I think draggables should be similar. I was able to make it work by using 'clone' instead of the default 'orginal' and using appendTo: 'body'. It's weird because if you use original as the helper it doesn't seem to append the helper to the body even though you would think it should if you set appendTo:'body'. I hope you can get it working!

Scott Morrison
I was able to get this to work using the {helper: 'clone', appendTo : 'body'} options
lomaxx
A: 

Try

$( ".selector" ).draggable({ appendTo: 'body' });