Not sure if there is an "API" way. But if you look at the source code (line 64-81)
if( $(this).parent().hasClass('directory') ) { if( $(this).parent().hasClass('collapsed') ) { // Expand if( !o.multiFolder ) { $(this).parent().parent().find('UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing }); $(this).parent().parent().find('LI.directory').removeClass('expanded').addClass('collapsed'); } $(this).parent().find('UL').remove(); // cleanup showTree( $(this).parent(), escape($(this).attr('rel').match( /.*\// )) ); $(this).parent().removeClass('collapsed').addClass('expanded'); } else { // Collapse $(this).parent().find('UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing }); $(this).parent().removeClass('expanded').addClass('collapsed'); } } else { h($(this).attr('rel')); }
It looks like you can call another function inside the hasClass('directory') if hasClass('directory') , and it will work.
So you could:
Change line 36 to
fileTree: function(o, h, dire) {
Between 65 and 66 add
dire($(this).attr('rel'));
If you want to have more control / flexibility / information, you can do dire($(this)); , and it will send a jQuery object instead of the rel attribute.
Example:
$(document).ready( function() { $('#container_id').fileTree({ root: '/some/folder/' }, function(file) {
I have not tested it, you may need to change a couple of things.
source share