admin管理员组文章数量:1366123
I have installed and trying to customize Jquery File Tree so that, on click of folder name, the folder name and path are returned to the calling function. Currently it only expands and collapses folders, and returns the file name on click of file.
So I need to return the folder too and cannot see where that is triggered.
I am using the php connector. Below link is where I downloaded the sample code: /
thanks, Ed
I have installed and trying to customize Jquery File Tree so that, on click of folder name, the folder name and path are returned to the calling function. Currently it only expands and collapses folders, and returns the file name on click of file.
So I need to return the folder too and cannot see where that is triggered.
I am using the php connector. Below link is where I downloaded the sample code: http://abeautifulsite/blog/2008/03/jquery-file-tree/
thanks, Ed
Share Improve this question asked Oct 22, 2010 at 21:09 EddEdd 411 silver badge2 bronze badges 1- Add your connector script and your current jQuery and I will tell you what is needed. – Liam Bailey Commented Oct 22, 2010 at 21:29
2 Answers
Reset to default 8Not sure if there is an "API" way to do it. 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'));
}
Looks like you can call another function inside the hasClass('directory')
if clause and it will work.
So you could:
Change Line 36 to be
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 the jQuery object instead of just the rel
attribute.
Example:
$(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
});
});
I have not tested it, you might need to change a couple of things around.
It worked pretty well, I just changed the last function to "dire", like it was it the code between line 65 and 66
... function(dire){
// do something when a dir is clicked
}
本文标签: javascriptJquery File Treehow to return folder name on folder clickStack Overflow
版权声明:本文标题:javascript - Jquery File Tree - how to return folder name on folder click - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743803050a2541671.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论