1

It might seem a little dull and basic, but I'm actually having trouble to find a good solution to my problem.

I'm using jQuery to make nice draggable elements. What I'd like to do is to anchor the draggable element wherever I want, with a button/link there is on it.

You could think of disable/enable the draggable when the button is clicked : it has the effect I want, but it sets a weird effect on the draggable, rendering it half white (which is the effect you would expect from disable, I'm not arguing on that).


Bottom-line is : how do I apply - and more importantly - remove the draggable property on the element? Is there any sort of :

$( "#draggable" ).draggable(false);

that would simply make my element normal again, or just prevent it from moving without altering its appearance?

Thanks in advance!

Edit : I have used the .draggable("disable") function and it changes the element's appearance, therefore I'm looking for another solution.

Gabriel Theron
  • 1,346
  • 3
  • 20
  • 49

2 Answers2

3

Yes you can disable the element from being draggable :

$('#draggable').draggable( "disable" );

See the docs here

Manse
  • 37,765
  • 10
  • 83
  • 108
  • But it actually disables it, putting a visual effect on it. I don't want it to change appearance, simply behavior. I'll take a look at the docs though, thanks! – Gabriel Theron May 29 '12 at 11:07
  • 1
    @GabrielTheron appearance can be fixed using CSS surely ? – Manse May 29 '12 at 11:09
0

Do a google search before you ask a question, thanks =)

This disables draggable

myObject.draggable( 'disable' )

This enables it

myObject.draggable( 'enable' )

There was already question here answering your question: How do I disable a jquery-ui draggable?

Community
  • 1
  • 1
pandavenger
  • 1,017
  • 7
  • 20
  • As I specified in my question and earlier comment, I have tested this function already, and do not want to use it because it alters the appearance of my elements. Do you know a way to have this function alter the behavior of the element without changing its appearance with "disable" function? – Gabriel Theron May 29 '12 at 11:11
  • 1
    You'd think you would have figured out to appearance would have been a css issue. Well, you got your answer, good luck in whatever you're trying to do. – pandavenger May 29 '12 at 12:06