I have a draggable <div>
with overflow
set to auto
to show a scrollbar when the content is too wide.
I want the entire content of the <div>
to be draggable, so I have not added a handle. Now when I try to drag the scrollbar, the entire <div>
is dragged instead of scrolling the content.
Is there a way of excluding an element from the handle of a draggable <div>
in jQuery?
I need something like:
$("#element").draggable({
handle: "not(#thisTable)"
})
Is there a way of doing this with selectors or something like that?
Limit draggable area using 'containment' option It is simple. All you have to do is, add an option called containment to the draggable() method. The containment option has a value parent.
The jQuery UI Draggable disabled Option is used to disable the draggable element if its value is set to true. Syntax: $( ". selector" ).
jQueryUI provides draggable() method to make any DOM element draggable. Once the element is draggable, you can move that element by clicking on it with the mouse and dragging it anywhere within the viewport.
tnx for your answer, but i found what i think is a better solution....
there is another option for draggable called 'cancel' and it excludes the selected element from the handle of the draggable element...
$('#container').draggable('option', 'cancel', '#excludedElement');
hope this helps someone else...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With