2

After reading the API.

My best guess is, initialize it using

j_obj.draggable();

and from there you can enable it ( set by default ).

j_obj.draggable("enable");

or disable it using

j_obj.draggable("disable");

where j_obj is the jquery object.

This works, but I kind of guessed after scrolling through the api here:

http://api.jqueryui.com/draggable/

I just wanted to verify that these 3, and only these 3 steps are required when you want to be able to enable and disable draggability as needed.

Basically an initialization of sorts, and then an enable and disable method.

1 Answers1

2

Yes, only these 3 steps are required when you want to be able to enable and disable draggability, Unless you need to listen for event's associated with dragging, you need to use other option's as described here

For example If you want to listen for dragStart :

j_obj.draggable({
  start: function( event, ui ) {
    // dragging started
  }
});

Or this Way :

j_obj.on( "dragstart", function( event, ui ){...});
Adil Shaikh
  • 44,509
  • 17
  • 89
  • 111
  • ... just curious ... would you know how I could save the x,y coordinates of where the box(I'm dragging a box) was dragged to? –  Apr 21 '13 at 21:52
  • You can use `.offset()` .. see this for example -http://stackoverflow.com/questions/4903530/how-to-get-the-position-of-a-draggable-object – Adil Shaikh Apr 21 '13 at 21:53