也许我不明白克隆如何与可排序一起工作,但这就是我想要做的。
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="ajax.googleapis/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="ajax.googleapis/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!
更多推荐
可排序的克隆助手无法正常工作
发布评论