StudioTime
StudioTime

Reputation: 23959

Make one element non-draggable

I have a bunch of elements on a page which are draggable and determined by:

$( ".folder" ).draggable({ revert: true });

I need to make one element, which has class .folder, not able to be dragged (it's the top folder in a tree).

I tried removing the class ui-draggable from it but that didn't work so I'm guessing the above code overrides it?

Is this possible?

NOTE: I can't simply change the class name as they are also droppable and the top folder in the tree is also droppable.

Upvotes: 0

Views: 132

Answers (3)

Ishan Jain
Ishan Jain

Reputation: 8161

Try also this:

$(".folder:not(YourElement)").draggable();

Upvotes: 0

maverickosama92
maverickosama92

Reputation: 2725

just use:

$( ".folder" ).draggable("disable"); //or enable

Upvotes: 0

Rohan Kumar
Rohan Kumar

Reputation: 40639

Try this,

$(".folder:not(:first)").draggable({ revert: true });

Read :not and :first selectors

Upvotes: 1

Related Questions