Make the highlighted changes in your code in the corresponding sections and there will be a small delay before the link redirect to the corresponding location. Within this short delay the user will be able to view the collapse of all the submenus other than the clicked one.
Code:
SDMenu.prototype.collapseNonActive = function(anchor,submenu){
for (var i = 0; i < this.submenus.length; i++){
if (this.submenus[i] === submenu){continue;}
if(submenu.className != 'collapsed')
this.collapseMenu(this.submenus[i]);
}
setTimeout(function(){location.href = anchor.href;},1000);
return false;
};
Code:
window.onload = function() {
var as = document.getElementById('my_menu').getElementsByTagName('a');
for(var i = 0; i < as.length; ++i){
as[i].onclick = function(){
return myMenu.collapseNonActive(this,this.parentNode);
};
}
myMenu = new SDMenu("my_menu");
myMenu.init();
};
I've tested this in FF 3.0.3 and IE 7
Hope this helps.
Bookmarks