1
votes

I implemented a treeview with context menus. I would like to have two sepearate context menus with different options, one for folders and the other for leaves.

My tree is built from a nested html tree. Since I am building this tree using a mako template, I know which nodes are trees and folders. Each node is either a <li class="folder"> or `.

I am currently using oFolderContextMenu.cfg.setProperty("trigger", YAHOO.util.Dom.getElementsByClassName("folder")); but the problem is that only top level folders have context menus.

I would like the subfolders to also have the menus. Folders and subfolders all have the "folder" class. I also tried setting the trigger in the oFolderContextMenu definition but end up with the same problem.

1

1 Answers

1
votes

You can collect all your DOM elements which you want to use as trigger into an array and then pass them to the configuration. With the native function "concat" you can join one ore more arrays into one.

example:

var triggerNodes, foldernodes, folder;
foldernodes = YAHOO.util.Dom.getElementsByClassName("foldernode");
folder = YAHOO.util.Dom.getElementsByClassName("folder");
triggerNodes = foldernodes.concat(folder);

oFolderContextMenu.cfg.setProperty("trigger", triggerNodes);

concat documentation - http://www.w3schools.com/jsref/jsref_concat_array.asp