0

JS:

function handDrag(dragHand)
{
    if(dragHand ==true)
    {
        //live query to auto bind the drag function to all elements of the cardsHand class even auto generated ones
        $('#playerHand') 
            .livequery('mouseenter', function(e){
            $('img.playerCardsHand').draggable
                ({ 
                    zIndex: 1000, 
                    revert: 'invalid',
                    stack: '.playerCardsHand',
                    selectedCard: 'widget',
                    addClasses: 'false',
                    disabled : false
                 }); 
            });
    }
    else
    {
        $('img.playerCardsHand').draggable({ disabled: true });
    }
}

function swapCards()
{
    handDrag(true);
}

function ready()
{
    handDrag(false);
}

Basically I call swapCards() I want to be able to drag my cards around the screen and drop them.

I then hit ready and it calls the ready() method. I then want my cards to no longer be draggable.

However now it keeps them draggable. I have tried removing the disabled: false to the swapCards draggable initialization but when I do that when I try and re-enable the draggable using

handDrag(true);

it won't re-enable the dragging.

Any ideas?

LOTW
  • 1
  • 1

1 Answers1

0

The syntax appears to be as follows:

$('img.playerCardsHand').draggable( "disable" );

See http://api.jqueryui.com/draggable/#method-disable

You might also need to enable it the next time you call handDrag(true);

if(dragHand ==true)
{
    $('img.playerCardsHand').draggable( "enable" );
    // etc
zoee
  • 93
  • 1
  • 7
  • I tried that before as well. I get the error : Uncaught Error: cannot call methods on draggable prior to initialization; attempted to call method 'disable' – LOTW Mar 16 '13 at 02:23