本帖最后由 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
非常感谢!!
