Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable a jquery-ui draggable?

Tags:

jquery-ui

How do I disable a jQuery draggable, e.g. during an UpdatePanel postback?

like image 782
ErnieStings Avatar asked Aug 24 '09 18:08

ErnieStings


People also ask

How do I delete a draggable element?

We can disable drag and drop on HTML elements by setting the draggable attribute to false . We set draggable to false so we can't drag it. We add event listeners for the dragstart and drop events with addEventListener .

What is jQuery draggable?

Draggable() Method This method allows the elements to be dragged with the help of mouse. Using jQuery UI, we can make the DOM(Document Object Model) elements to drag anywhere within the view port. This can be done by clicking on the draggable object by mouse and dragging it anywhere within the view port.

What is UI draggable?

jQuery UI draggable() method is used to make any DOM element draggable. Once the element is made draggable, you can move it by clicking on it with the mouse and drag it anywhere within the viewport.

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.


2 Answers

Could create a DisableDrag(myObject) and a EnableDrag(myObject) function

myObject.draggable( 'disable' ) 

Then

myObject.draggable( 'enable' ) 
like image 177
madcolor Avatar answered Oct 06 '22 12:10

madcolor


To temporarily disable the draggable behavior use:

$('#item-id').draggable( "disable" ) 

To remove the draggable behavior permanently use:

$('#item-id').draggable( "destroy" ) 
like image 29
PhilB Avatar answered Oct 06 '22 12:10

PhilB