Hi, I'm new using jQuery and my english is not very good ups!
Well, I was using this plugin, copy&paste of the header
/*
* Async Treeview 0.1 - Lazy-loading extension for Treeview
*
* http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
*
* Copyright (c) 2007 Jörn Zaefferer
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Revision: $Id$
*
*/
I think I found 2 minor bugs in file jquery.treeview.async.js:
function createNode(parent) {...} <- only one parameter but...
in the code it's called like:
There's a second parameter ("branch") that I think could be deleted like:
- createNode.call({
classes: "placeholder",
text: " ",
children: []
}, branch);
I tested it and works fine.
- createNode.call({
classes: "placeholder",
text: " ",
children: []
}); //, branch);
The second thing I've found is:
this.children is always undefined, because the property is called hasChildren. So I commented those lines with no side-effects.
- if (this.children && this.children.length) {
$.each(this.children, createNode, [branch])
Another thing I wanted is to add/remove nodes from the tree. Fortunately the add function is in the plugin and works fine, but not the delete ¿?
So to delete nodes I've done:
Where Element is the ID of the node to delete, each of the <li> of the tree has a unique one.
- if($(Element).hasClass("lastExpandable") || $(Element).hasClass("lastCollapsable")) {
if ($(Element).prev().hasClass("collapsable"))
{
$(Element).prev().addClass("lastCollapsable");
$(Element).prev().children("div").addClass("lastCollapsable-hitarea");
}
if ($(Element).prev().hasClass("expandable"))
{
$(Element).prev().addClass("lastExpandable");
$(Element).prev().children("div").addClass("lastExpandable-hitarea");
}
}
$(Element).remove();
The question is, for the minor bugs are those modifications correct? And for the delete nodes: is the correct way to do it?
Hope this helps
Alex