[ 3 posts ]

Jong-won Choi

  • Username: pbp
  • Joined: Tue Feb 15, 2011 7:52 pm
  • Posts: 5
  • Offline
  • Profile

Adding an item on the top instead of bottom.

Post Posted: Sun Feb 20, 2011 6:54 pm
+0-
Hi all

I want to achieve behaviour like below code and I wonder if there is better approach. Any idea?

Thanks!

- php

Code:
 
  actionsContainer.on("itemAdded", function (e) {
            var items = actionsContainer.get('items');

            // push a new item on the top
            if (items.length > 1) {
                var targetItem = items[0].get('boundingBox');
                var srcItem = e.item.get('boundingBox');
                var cb = actionsContainer.get('contentBox');
                cb.insertBefore(srcItem, targetItem);
                // maintaing items list
                items.splice( items.length - 1, 1 );
                items.splice( 0, 0, e.item );
            };
        });

Iliyan Peychev

YUI Contributor

  • Username: peychevi
  • Joined: Tue Feb 24, 2009 12:38 pm
  • Posts: 136
  • Location: Varna, Bulgaria
  • Twitter: ipeychev
  • GitHub: ipeychev
  • Gists: ipeychev
  • Offline
  • Profile

Re: Adding an item on the top instead of bottom.

Post Posted: Mon Feb 21, 2011 7:44 am
+0-
Use:
var items = accordion.get( "items" );

accordion.addItem( item, items[0] );

Iliyan

Jong-won Choi

  • Username: pbp
  • Joined: Tue Feb 15, 2011 7:52 pm
  • Posts: 5
  • Offline
  • Profile

Re: Adding an item on the top instead of bottom.

Post Posted: Tue Feb 22, 2011 1:56 pm
+0-
Iliyan

Of couse!

I am an idiot and should not write in Javascript!

The Accordion item closing confirmation chage works fantastically well as well!

Thanks again

- php
  [ 3 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum