【发布时间】:2012-10-19 00:22:39
【问题描述】:
这里和网络上有很多关于如何保存 jquery 可排序列表的状态的帖子,但是恢复一个呢?
在我的例子中,我正在组织一个页面布局,而不是一个列表,所以我将有一个左右列(或更多)。
这是我过去所做的(使用php+smarty):
<div id="leftsort">
{section loop=$leftSort name="ls"}
{if $leftSort[ls]}{include file="index/sort/`$leftSort[ls]`.tpl"}{/if}
{/section}
</div>
<div id="rightsort">
{section loop=$rightSort name="rs"}
{if $rightSort[rs]}{include file="index/sort/`$rightSort[rs]`.tpl"}{/if}
{/section}
</div>
每个portlet 都有自己包含的模板文件。当我保存可排序列表的状态时,我将左右列分开保存,以便于恢复。
您将如何恢复可排序列表?
我更喜欢纯 jquery 方式,例如 - 将 portlet 隐藏在页面上,将 json 数组传递给可排序列表,然后在“创建”时对其进行排序并显示 portlet
$( ".selector" ).sortable({
create: function(event, ui) {
-- load sortable positions in a json array --
-- parse the array and move the hidden portlets into position --
-- show portlets --
}
});
对我来说,并不完全需要特定的代码,因此任何概念或想法都值得赞赏。
谢谢!
【问题讨论】:
标签: php jquery jquery-ui-sortable smarty3