可排序的克隆助手无法正常工作 [英] Sortable clone helper not working

查看:93
本文介绍了可排序的克隆助手无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许我不明白克隆如何与可排序一起工作,但这就是我想要做的。

Maybe I don't understand how clone works with sortable, but here is what I would like to do.

在对项目进行排序时,我希望保留一个项目的克隆,直到我停止将项目放在新位置。

When sorting an item I would like a clone of the item I am dragging remain until I stop drop the item in its new position.

以下是代码:

<html>
<head>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"></script>

    <style type="text/css">
        .sort { width: 150px; }
        .ui-state-highlight { background-color: #000; height:2px; }
    </style>
</head>
<body>
    <div>
        <ul class="sort">
            <li>Item 1</li>
            <li>Item 2</li>
            <li>Item 3</li>
            <li>Item 4</li>
        </ul>
    </div>

    <script type="text/javascript">
        $(function() {
            $('.sort').sortable({
                helper: 'clone',
                placeholder: 'ui-state-highlight',
                opacity: '.5'
            })
        })
    </script>
</body>
</html>

提前感谢您的帮助!

推荐答案

当您使用克隆选项时,开始拖动时,原始项目将隐藏 style =display:none。您可以将处理程序附加到sort事件(或隐藏原始项目的任何事件)以重新显示它。那么一切都适合你。

When you use the clone option, the original item is hidden with style="display: none" when you start dragging. You could attach a handler to the sort event (or whatever event hides the original item) to re-show it. Everything should work for you then.

P.S。我使用 Firebug 来查看原始元素发生了什么。如果你没有使用它,你真的应该是!

P.S. I used Firebug to look at what was happening to the original element. If you're not using it you really ought to be!

这篇关于可排序的克隆助手无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆