![](/img/trans.png)
[英]jQuery UI - programatically move a dropped draggable to another “available” droppable
[英]Disable draggable JQuery UI once it dropped in Droppable section
我有两个div部分,我正在执行拖放和可排序操作,我在可拖动部分中有5条可拖动记录的列表,我想在放下droppable部分时立即禁用可拖动记录,以避免重复的记录放置在droppable div中部分
HTML代码
<div>
<form method="post" action="">
<ol style='list-style:decimal' id="qselected"></ol>
</form>
</div>
<br/>
<div>
<ul id="qlist">
<?php
for($i=1;$i<=5;$i++)
{
?>
<li id='article_<?php echo $i;?>' >
<div class="qitem" style='margin-bottom : 20px;border-bottom:1px solid #e7e7e7;'>
<span data-item="1" class="question">Value : <?php echo $i;?></span>
</div>
</li>
<?php
}
?>
</ul>
</div>
JQUERY代码
$(document).ready(function() {
$("#qselected").disableSelection();
$(".qitem").draggable({
containment : "#container",
tolerance:"pointer",
helper : 'clone',
refreshPositions: true ,
revert : 'invalid',
opacity:.4
});
$("#qselected, #qlist").droppable({
revert:true,
hoverClass : 'ui-state-highlight',
greedy: true,
refreshPositions: true,
drop : function(ev, ui) {
$(ui.draggable).clone().appendTo(this);
if($(this)[0].id === "qselected")
{
console.log($(this).closest("button").find('.hello'));
$(this).find('.hello').hide();
$(this).find('.btn').show();
return true;
}
},
}).sortable({
revert: true,
refreshPositions: true ,
helper : 'clone',
cursor: "move",
delay: 1,
tolerance: 'pointer',
revert: 50
});
});
在您的放置函数中执行以下操作:
ui.draggable.draggable( 'disable' );
这是根据您的代码为您准备的小提琴: http : //jsfiddle.net/j6dqk54p/1/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.