I have two div section were I'm performing drag/drop and sortable operations i have list of 5 draggable records in my draggable section I want to disable the draggable record as soon as I drop in droppable section to avoid duplicate records placed in droppable div section
HTML CODE
<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 CODE
$(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
});
});
In your drop function do this:
ui.draggable.draggable( 'disable' );
Here is a fiddle for you based on your code: http://jsfiddle.net/j6dqk54p/1/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.