Show Hide Problem
Show Hide Problem
Hi I know almost nothing about JQuery, but I have inherited some code that doesnt quite work.
Im sorry if this is really simple.
Its a show hide on a file list, where the folders should toggle open and close while the files should be clickable. However the links have the same action as the folders, ie the a href link is overridden and they toggle the area show hide as well.
This is the JQuery code:-
-
registerFileTreeEvents = function(){
$('ul.fileTree li.subfolder').each( function( i ){
$(this).toggle( function(){
$(this).attr('class','subfolderOpen');
$(this).children('ul').show();
//console.log( this )
},function(){
$(this).attr('class','subfolder');
$(this).children('ul').hide();
//console.log( this )
})
})
$('ul.fileTree ul').each( function( i ){
//console.count("Ul elements");
$(this).hide();
/*//$(this).css('background-color','#eee');
$(this).toggle( function(){
$(this).show();
console.log( this );
},
function(){
$(this).hide();
console.log( this );
}
)*/
})
While the folders structure is a list with top level ul class as filetree, then the folders as an li class of subfolder while the files are held in an li class of file.
Thanks in advance for any help.