日期:2014-05-16  浏览次数:20578 次

关于 UI 中的 accordion
本帖最后由 wrost 于 2013-11-20 15:58:02 编辑

这个accordion刷新后,仍然保持刚才打开的那个 主菜单,请问是怎么实现的
demo
http://www.wangjie.org/css-menu/demo/112xiala/
源码:
http://www.wangjie.org/css-menu/detail-6511.aspx


jquery ui 的 accordion 一刷新,就不能保持打开的那个 主菜单
http://jqueryui.com/accordion/

------解决方案--------------------
写个cookie

$(window).bind('unload', function(){ //clean up and persist on page unload
$('.'+config["headerclass"]).unbind()
var expandedindices=[]
$('.'+config["contentclass"]+":visible").each(function(index){ //get indices of expanded headers
expandedindices.push($(this).attr('contentindex'))
})
if (config.persiststate==true && $('.'+config["headerclass"]).length>0){ //persist state?
expandedindices=(expandedindices.length==0)? '-1c' : expandedindices //No contents expanded, indicate that with dummy '-1c' value?
ddaccordion.setCookie(config.headerclass, expandedindices)
}
})

很坏啊 在unload的时候才记录 那个面板被关闭

ddaccordion.setCookie(config.headerclass, expandedindices)
------解决方案--------------------
是啊 你看那段代码
ddaccordion.setCookie(config.headerclass, expandedindices)
这个方法里面就是写cookie的封装
当加载页面的时候 还有个 getCookie