开发者

jQuery $(ui.draggable).remove() not working with IE

I can get IE to remove objects as long as it is not the current draggable object. This is working on Chrome and Firefox. Is there something I'm doing wrong?

<html>
<head&开发者_StackOverflowgt;
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script src="http://code.jquery.com/ui/jquery-ui-git.js"></script>
</head>
<body>
    <ul id="list">
    <li id="test-1" class="dropme">One</li>
    <li id="test-2" class="dropme">Two</li>
    </ul>
    <div id="bucket" style="border:1px solid black">
        <p>Drop items here and they should be removed.</p>
    </div>
    <script>
        $("#list").sortable({
        items: 'li'
    });   
    $('#bucket').droppable({
        drop: function(event, ui) {
            $(ui.draggable).remove();
        },
        accept: '.dropme'
    });   
    </script>
</body>
</html>


The ui.draggable and drop function are a little quirky in IE. Try this:

<html>
<head>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script src="http://code.jquery.com/ui/jquery-ui-git.js"></script>
    <script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script>
</head>
<body>
    <ul id="list">
    <li id="test-1" class="dropme">One</li>
    <li id="test-2" class="dropme">Two</li>
    </ul>
    <div id="bucket" style="border:1px solid black">
        <p>Drop items here and they should be removed.</p>
    </div>
    <script>
        $("#list").sortable({
        items: 'li',
        stop: function(event, ui) { 
            if (deleteMe) {
                        ui.item.remove();
                        deleteMe = false;
                    }
        }
    });   
    $('#bucket').droppable({
        drop: function(event, ui) {
            deleteMe = true; 
        },
        accept: '.dropme'
    });   
    </script>
</body>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜