首頁  >  文章  >  web前端  >  关于 UI 中的 accordion_html/css_WEB-ITnose

关于 UI 中的 accordion_html/css_WEB-ITnose

WBOY
WBOY原創
2016-06-24 12:25:221225瀏覽

本帖最后由 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)

写个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)


谢谢,这么说它是通过设置、读取cookie来实现的了? 对吗

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

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

非常感谢!!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn