Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Insert a link using javascript (Read 1460 times)
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Insert a link using javascript
Jul 29th, 2011 at 10:40am
Print Post  
I am creating a node and linking it to a parent using javascript. What I would like to do is add this to a specific point in the parents links.

For example, I have a parent with 4 child nodes labelled a,b,d and e. I am now adding c using javascript. But the javascript only adds the node to the end. I would like to insert it after b, and before d.

Here is what I have so far:

       function addBoxToNode(parentNode, addBoxAt) {
           var node = diagram.getFactory().createShapeNode(50, 50, 24, 14);
           node.setTag('box');
           node.setBrush(script.createSolidBrush(170, 210, 240));
           node.setText('test');
           var link = diagram.getFactory().createDiagramLink(parentNode, node);
           var links = parentNode.getOutgoingLinks();

           return node;
       }
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Insert a link using javascript
Reply #1 - Jul 29th, 2011 at 11:14am
Print Post  
You can probably shuffle the links in the returned collection to change their ordering. Like this:

Code
Select All
links.remove(link);
links.add(2, link); 


Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint