Edd*_*Edd 4 javascript treeview tree jquery file
我已经安装并尝试自定义Jquery文件树,以便在单击文件夹名称时,将文件夹名称和路径返回给调用函数.目前它只展开和折叠文件夹,并在点击文件时返回文件名.
所以我也需要返回文件夹,看不到触发的位置.
我正在使用php连接器.下面链接是我下载示例代码的地方:http: //abeautifulsite.net/blog/2008/03/jquery-file-tree/
谢谢,艾德
不确定是否有"API"方式来做到这一点.但是如果你看一下源代码(第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'));
}
Run Code Online (Sandbox Code Playgroud)
看起来你可以在hasClass('directory')if子句中调用另一个函数,它会起作用.
所以你可以:
改变第36行
fileTree: function(o, h, dire) {
Run Code Online (Sandbox Code Playgroud)
65到66之间加
dire($(this).attr('rel'));
Run Code Online (Sandbox Code Playgroud)
如果你想拥有更多的控制/灵活性/信息,你可以这样做dire($(this));,它将发送jQuery对象而不仅仅是rel属性.
例:
$(document).ready( function() {
$('#container_id').fileTree({ root: '/some/folder/' }, function(file) {
// do something when a file is clicked
}, function(dir){
// do something when a dir is clicked
});
});
Run Code Online (Sandbox Code Playgroud)
我没有测试过,你可能需要改变一些事情.