Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude item from handle on jQuery draggable

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?

like image 385
Fortes Avatar asked Sep 22 '09 21:09

Fortes


People also ask

How do I limit a draggable area?

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.

How do I delete a draggable element?

The jQuery UI Draggable disabled Option is used to disable the draggable element if its value is set to true. Syntax: $( ". selector" ).

How does jQuery ui draggable work?

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.


1 Answers

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...

like image 90
Fortes Avatar answered Oct 22 '22 09:10

Fortes