在Droppable部分删除后,禁用可拖动的JQuery UI

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
            });
    });
查看全部
dongtou9934
dongtou9934
2015/10/02 05:30
  • php
  • html
  • javascript
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复