>  기사  >  웹 프론트엔드  >  关于 UI 中的 accordion_html/css_WEB-ITnose

关于 UI 中的 accordion_html/css_WEB-ITnose

WBOY
WBOY원래의
2016-06-24 12:25:221317검색

本帖最后由 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으로 문의하세요.