jQuery UI可排序动态固定项 [英] jQuery UI Sortable dynamic fixed items
问题描述
我需要一些帮助,让一些项目保持在jquery UI可排序的位置。
I need some help with getting some items to stay in place in a jquery UI sortable.
我知道 JQuery可排序列表和固定/锁定项目并且它确实工作得非常好,问题是如果你这样工作正常不要添加项目。如果你向sortable添加更多项目,你必须再次调用.fixedsortable,我想避免这种情况。
以下是我的设置示例:
I know about JQuery sortable lists and fixed/locked items and it does work quite nicely, the problem is that this works fine if you're not adding items. If you add more items to the sortable you have to call .fixedsortable again and I'd like to avoid that. Here's an example of my setup:
<ul>
<li></li>
<li class="fixed"></li>
<li></li>
<li class="fixed"></li>
<li></li>
</ul>
我需要固定类在排序时保持原位。
I need the "fixed" class to remain in place when sorting.
推荐答案
您可以使容器元素可排序
,这样您就不必担心新元素:
You can make container element sortable
so that you will not have to worry about new elements:
HTML:
<ul id="container">
<li>1</li>
<li class="fixed">2</li>
<li>3</li>
<li class="fixed">4</li>
<li>5</li>
</ul>
JS:
$("#container").sortable();
这篇关于jQuery UI可排序动态固定项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!