[ 5 posts ]

Christopher Bargren

  • Username: chrisb
  • Joined: Fri Mar 11, 2011 11:31 am
  • Posts: 13
  • Offline
  • Profile
Tags:

Preventing accordion item expansion

Post Posted: Fri Mar 11, 2011 11:46 am
+0-
Hey,
First off, thanks for creating accordion. It's a very nice tool.

I was wondering if there's an easy way to prevent an accordionItem from expanding after it has been clicked. I only want a couple of them to be open at once.

I.E.:
Code:
accordionItem.on('expandedChange', function(e) {
            if (!accordionItem.get('expanded')) {
               if (expandedItems < 2) {
                  expandedItems++;
               }
               else {
                  e.preventDefault();
                  return false;
               }
            }
         });


This doesn't seem to work though, for whatever reason. I've tried to stop the event's propagation as well, which also fails to work. Is there a way to do this?

Thanks,
Chris

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: Preventing accordion item expansion

Post Posted: Mon Mar 14, 2011 11:55 am
+0-
Chris,

chrisb wrote:
I was wondering if there's an easy way to prevent an accordionItem from expanding after it has been clicked. I only want a couple of them to be open at once.


This is currently not supported.

I can add a new event, something like 'itemChosen'. You will be able to cancel the action, which follows - expanding, collapsing, set as always visible or closing an item.
OK?

Iliyan

Christopher Bargren

  • Username: chrisb
  • Joined: Fri Mar 11, 2011 11:31 am
  • Posts: 13
  • Offline
  • Profile

Re: Preventing accordion item expansion

Post Posted: Mon Mar 14, 2011 4:08 pm
+0-
That would be awesome. Thanks a lot, Iliyan. And thanks for your speedy response too.

Chris

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
Tags:

Re: Preventing accordion item expansion

Post Posted: Sun Mar 20, 2011 1:34 am
+0-
Committed to GitHub. Basicly, you may prevent an user action in this way:

Code:
accordion.on('itemChosen', function(event){
    event.preventDefault();
});


event param contains information about the item and whether user clicked on 'set as always visible' icon or 'close' icon.

Once they publish that version to Yahoo! CDN, I will update the documentation.

Iliyan

Christopher Bargren

  • Username: chrisb
  • Joined: Fri Mar 11, 2011 11:31 am
  • Posts: 13
  • Offline
  • Profile

Re: Preventing accordion item expansion

Post Posted: Mon Mar 21, 2011 8:02 am
+0-
Sweet! That was quick. :D Thanks again. I'll be putting this to good use shortly!

Thank you!
Chris
  [ 5 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