Question

How do you detect if a clicked node is a folder ?

I wish to find out if a clicked node is a folder to modify right-click behaviour (if not folder => do something).

Was it helpful?

Solution

Once you have a node, you can test for node.data.isFolder.

In Dynatree event handler this is straightforward:

For example

onClick: function(node, event) {
    if(node.getEventTargetType(event) === "title" && node.data.isFolder){
        [...] // Handle the click event
        return false;// Prevent default processing
    }
}

From inside a custom handler you might first have to find the node from the target element:

var node = $.ui.dynatree.getNode(el)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top