I copied part of their js.
// populates the menu according to what link was clicked, opens it if not already opened
populateMenu: function (currentLink) {
dd.removeClass(pages);
dd.addClass(currentLink + " open");
dd.slideDown(speed, function () {
// callback that runs after menu finishes sliding down
$("nav ul li.menu>a.active").find("span").html(upArrow);
// ajax call is below; it appends a timestamp to prevent caching, in case of dynamic content; remove if you like
dd.load(dir + "/" + currentLink + ext + "?" + new Date().getTime(), function () {
// callback that runs after menu finishes loading
dd.removeClass("loading");
addCloseLink();
});
});
// change the hash according to the clicked link
document.location.hash = currentLink;
},
If you change the dd.load call for a modify statement with jQuery like dd.html(...) with the content of your choice, you do not have to use ajax.
If you remove the document.location.hash = currentLink; line at the end of the function, it will not modify your back/forward navigation.
That would end up looking something like:
populateMenu: function (currentLink) {
dd.removeClass(pages);
dd.addClass(currentLink + " open");
dd.slideDown(speed, function () {
// callback that runs after menu finishes sliding down
$("nav ul li.menu>a.active").find("span").html(upArrow);
dd.html($('#your_source_here'));
dd.removeClass("loading");
addCloseLink();
});
},
Edit:
You could also use a jQueryUI tabs with collapsible content, see demo here. It would require styling but should work with maybe less work than adapting the previous code.
See this jsFiddle for a basic example. Only the styling of the tabs need to be done.
这段代码展示了如何使用jQuery实现点击链接时动态填充菜单,并通过AJAX防止内容缓存。当链接被点击时,菜单会下滑显示,同时更新页面hash。通过修改dd.load为dd.html可以直接插入自定义内容,而无需使用AJAX。此外,还建议使用jQuery UI tabs实现可折叠的内容,以简化代码。
903

被折叠的 条评论
为什么被折叠?



