How do I disable a jquery-ui draggable?

后端 未结 9 1451
萌比男神i
萌比男神i 2020-11-29 04:46

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

相关标签:
9条回答
  • 2020-11-29 05:38

    To enable/disable draggable in jQuery I used:

    $("#draggable").draggable({ disabled: true });          
    
    $("#draggable").draggable({ disabled: false });
    

    @Calciphus answer didn't work for me with the opacity problem, so I used:

    div.ui-state-disabled.ui-draggable-disabled {opacity: 1;}
    

    Worked on mobile devices either.

    Here is the code: http://jsfiddle.net/nn5aL/1/

    enabledisabledraggablejqueryopacityproblemhtml

    0 讨论(0)
  • 2020-11-29 05:39

    Seems like no one looked at the original documentation. May be there was no it at that time))

    Initialize a draggable with the disabled option specified.

    $( ".selector" ).draggable({ disabled: true });
    

    Get or set the disabled option, after init.

    //getter
    var disabled = $( ".selector" ).draggable( "option", "disabled" );
    //setter
    $( ".selector" ).draggable( "option", "disabled", true );
    
    0 讨论(0)
  • 2020-11-29 05:44

    In the case of a dialog, it has a property called draggable, set it to false.

    $("#yourDialog").dialog({
        draggable: false
    });
    

    Eventhough the question is old, i tried the proposed solution and it did not work for the dialog. Hope this may help others like me.

    0 讨论(0)
提交回复
热议问题