2 Replies Latest reply on Oct 2, 2008 5:00 AM by (Dany_Vos)

    [CS3][JS] Changing order of a pageitem

      Hi All,

      I'm looking for a way to easily change the order of a pageitem with javascript. To be clear, with 'order' i mean which item is on top of the other, which item is behind another item, ...

      In both desktop and server you could achieve this by choosing Bring Forward(), sendToBack(), etc.
      But using these methods, if you want to rearrange 10 items in a specific way, you'll have to use some complex code to be able to put all items in the correct order.

      In the data browser you can find the order in the index property, with 0 being the frontmost item.
      What I'm looking for is a way to say:
      myPageitem1.index = 0;
      myPageitem2.index = 1;
      and so on.
      Unfortunately, the index property is read only, so this is not possible.

      Is there anybody who did something similar, or can guide me in the right direction?

        • 1. Re: [CS3][JS] Changing order of a pageitem
          (Simon_Paterson) Level 1
          Would it work if you created a list of the page items in the order you wanted them, and then cycled through them using the sendToBack() method? This would leave the first item on top by the time you've processed all the page items in your list.

          I'm trying to think of a way to randomly move a page item from one location in the stack to another, but I haven't thought of anything yet.
          • 2. Re: [CS3][JS] Changing order of a pageitem
            Level 1
            Hi Simon,

            I was hoping there would be a better way, this way each pageitem has to be rearranged a number of times before all items are correct. This doesn't seem very efficient to me.

            That said, I created a script to try your way and it works perfectly, and even faster then I thought.

            For now it'll do.

            Thanks !