简体   繁体   English

如何在jQuery UI中的Droppable中拖放后停止可拖动?

[英]How to Stop Draggable After Drop in Droppable in jQuery UI?

Can you please take a look at This Demo and let me know how I can Stop Dragging After Dropping in Droppable? 您能否看一下这个演示,并让我知道如何在拖放到Droppable之后停止拖动?

Here is the code I have 这是我的代码

$(function() {
    $( ".draggable" ).draggable({cancel:false});
    $( "#droppable-1" ).droppable({
      drop: function( event, ui ) {
             $( this ).addClass( "ui-state-highlight" );
      }
    });
        $( "#droppable-2" ).droppable({
      drop: function( event, ui ) {
             $( this ).addClass( "ui-state-highlight" );
      }
    });
        $( "#droppable-3" ).droppable({
      drop: function( event, ui ) {
             $( this ).addClass( "ui-state-highlight" );
      }
    });
  });

and here is the HTML 这是HTML

<button type="button" id="App-1" class="btn btn-default btn-xs draggable">App-1</button>
<button type="button" id="App-2" class="btn btn-default btn-xs draggable">App-2</button>
<button type="button" id="App-3" class="btn btn-default btn-xs draggable">App-3</button>

<div id="droppable-1" class="droppable ui-widget-header"></div>
<div id="droppable-2" class="droppable ui-widget-header"></div>
<div id="droppable-3" class="droppable ui-widget-header"></div>

Use the disable method like in: 使用如下所示的禁用方法:

$( "#droppable-1" ).droppable({
   drop: function( event, ui ) {
      $( this ).addClass( "ui-state-highlight").disable();
   }
});

 $(function () { $( ".draggable" ).draggable({cancel:false}); $( ".droppable" ).droppable({ drop: function( event, ui ) { $(this).addClass( "ui-state-highlight").disable(); } }); }); 
 .droppable{ width: 70px; height: 30px; padding: 5px; } 
 <link href="//code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.min.css" rel="stylesheet"/> <script src="//code.jquery.com/jquery-1.11.3.js"></script> <script src="//code.jquery.com/ui/1.11.3/jquery-ui.js"></script> <button type="button" id="App-1" class="btn btn-default btn-xs draggable">App-1</button> <button type="button" id="App-2" class="btn btn-default btn-xs draggable">App-2</button> <button type="button" id="App-3" class="btn btn-default btn-xs draggable">App-3</button> <div id="droppable-1" class="droppable ui-widget-header"></div> <div id="droppable-2" class="droppable ui-widget-header"></div> <div id="droppable-3" class="droppable ui-widget-header"></div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM