cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

How to: Swap two child nodes of element by using Styler APP

JuhaA
7-Bedrock

How to: Swap two child nodes of element by using Styler APP

I have two div elements in section element. I would like to change order of those two div elements depending is element in even or odd pages. When I run PDF publish I don't get any errors. Any ideas or workarounds how to do this?

var currentNode = formatting.currentXMLNode;

if (formatting.currentPage.pageNumber % 2 == 0) {

//note! first element in section is title

  if (currentNode.childNodes[2]!=null && currentNode.childNodes[1] != null){

    currentNode.insertBefore(currentNode.childNodes[2],currentNode.childNodes[1]);

    formatting.write(currentNode.nodeName + " Child node1:" + currentNode.childNodes[1].nodeName + " Child node2:" + currentNode.childNodes[2].nodeName);

  }

}

ACCEPTED SOLUTION

Accepted Solutions
JuhaA
7-Bedrock
(To:JuhaA)

My mistake


var currentNode = formatting.currentXMLNode;

if (formatting.currentPage.pageNumber % 2 == 0) {

  if (currentNode.childNodes[2]!=null && currentNode.childNodes[1] != null){

    var firstDiv=currentNode.childNodes[1];

    var seconDiv=firstDiv.augNextSibling;

    firstDiv.insertBefore(seconDiv,firstDiv);

  }

  else

    formatting.write("Both are nulls_");

}

View solution in original post

1 REPLY 1
JuhaA
7-Bedrock
(To:JuhaA)

My mistake


var currentNode = formatting.currentXMLNode;

if (formatting.currentPage.pageNumber % 2 == 0) {

  if (currentNode.childNodes[2]!=null && currentNode.childNodes[1] != null){

    var firstDiv=currentNode.childNodes[1];

    var seconDiv=firstDiv.augNextSibling;

    firstDiv.insertBefore(seconDiv,firstDiv);

  }

  else

    formatting.write("Both are nulls_");

}

Announcements

Top Tags