可排序的克隆助手无法正常工作

编程入门 行业动态 更新时间:2024-10-26 01:32:37
本文介绍了可排序的克隆助手无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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!

更多推荐

可排序的克隆助手无法正常工作

本文发布于:2023-11-08 08:01:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1568808.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法正常   助手   工作

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!