I have a d3 tree and I want to be able to right click the node so that a new file is opened which lists the children of that node. How do I do this? Thank you
            Asked
            
        
        
            Active
            
        
            Viewed 3,965 times
        
    1 Answers
6
            
            
        In your code where you are creating the nodes and it's attributes you add...
.on('contextmenu',/* handler */);
So an example of this used in code would be...
node.enter().append("g")
        .attr("class", "node")
        .on('dblclick', /* handler for double click */ )
        .on('contextmenu', /* handler for right click */ );
As for reading in the file which I am assuming is a local text file you can reference
Javascript - read local text file
and just call the function you create in the .on.
.on('contextmenu', functionForReadFile);
- 
                    thank you very much, i would like it to open a new json file that lists the children though, not read in a file, if that makes sense – Veda May 18 '15 at 20:59
- 
                    It sounds like you want to 'create' a new file, can't open a new one if it doesn't exist. Are you wanting it to show the json data and have it save to a file? – Mike Weber May 18 '15 at 22:40
 
     
    