Addition: crumbtrail function

13 views
Skip to first unread message

Seidr

unread,
Dec 10, 2009, 4:02:45 AM12/10/09
to mootree
Out of neccesity, I've written a quick function that retrieves a comma-
delimited list of text values, leading down to your currently selected
item in the tree. You can modify this to return objects in an array
instead, so that all data is available, however for my heads the text
will suffice. Hope someone finds this useful.

Add this to the MooTreeControl class.

/*
Property: crumbtrail
Returns the current crumbtrail of the selected node
*/
crumbtrail: function() {
var crumbtrailString = "";
if (this.selected) {
var currentItem = this.selected;
while (currentItem.parent) {
crumbtrailString = (crumbtrailString=="")?
currentItem.text:currentItem.text+","+crumbtrailString;
currentItem=currentItem.parent;
}
}
return crumbtrailString;
}
Reply all
Reply to author
Forward
0 new messages