如何在JQuery Sortable上执行重置 [英] How do you perform a reset on a JQuery Sortable

查看:101
本文介绍了如何在JQuery Sortable上执行重置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JQuery Sortable.我想知道是否有可能,经过多次尝试,将可排序控件恢复到其原始状态,类似于表单重置. 取消"选项似乎只会影响最后一次排序尝试,而不会影响所有尝试.

I'm using JQuery Sortable. I'd like to know if it's possible to, after a number of resortings, restore the sortable control back to its original state similar to a form reset. The 'cancel' option only seems to affect the last sort attempt not all of them.

推荐答案

我个人喜欢这样做:

$("#sortable").sortable({config...});
var cache = $("#sortable").html();

重置时

$("#sortable").html(cache).sortable("refresh");

我尝试使用.clone()和.children()甚至$(#sortable> *),但发现将.html()缓存是最佳选择.

I tried using .clone() and.children() and even $("#sortable > *), but find caching the .html() the best option.

在我的情况下,我有两个关联的列表.一个包含当前用户可以排序或删除的项目,另一个包含用户可以从中获取并添加到当前项目"列表中的可用项目的列表.我需要一种将所有内容重置为原始状态的方法.以上效果很好.

In my situation, I have two connected lists. One containing current items the user can sort or remove and another list of available items that the user can grab from to add to the "current item" list. I needed a way to reset everything to original state. The above works great.

这篇关于如何在JQuery Sortable上执行重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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