Fixed accordions height ?
I’m wondering the same thing. A client just got in touch to complain about it. For now I’ve just overridden the height:602px; with auto !important; in the CSS but this is a bit of a hack and seems to have done something weird with the performance.
Thanks for the hack. I tried the autoheight function but it does nothing.
Same problem here. I have also used the auto!important fix but this has caused the animation to be really slow.
The hack totally breaks the smooth scrolling. I can not figure out where the accordion is getting the fixed height from.
Same problem here.
How did you override the CSS with auto!important?
I can’t figure out what class that controls it.
Okay, I just posted a very ugly hack for this, but then I hopped in to the jQuery Accordion docs and found one simple line that did the trick.
Please note this requires modifying the plugin itself, which I typically never condone, but it does the job and doesn’t really futz with the plugin too much.
In the plugin, starting on line 114 you’ll find this code
$query_atts = shortcode_atts( array( 'autoHeight' => false, 'disabled' => false, 'active' => 0, 'animated' => 'slide', 'clearStyle' => false, 'collapsible' => false, 'event' => 'click', 'fillSpace' => false ), $attr);
What you’re going to want to do is drop a new line in that shortcode_atts array that looks like this: ‘heightStyle’ => ‘content’
Don’t forget to include a , on the previous line if you’re adding. Here’s my code below
$query_atts = shortcode_atts( array( 'autoHeight' => false, 'disabled' => false, 'active' => 0, 'animated' => 'slide', 'clearStyle' => false, 'collapsible' => false, 'event' => 'click', 'fillSpace' => false, 'heightStyle' => 'content' ), $attr);
Again, it’s never ideal to modify the plugin like this, but it does work. If I can figure out how to properly integrate this in to where the user can set that variable I’ll fork the plugin on GitHub and see if I can get the original developer to pull it in to their version.
Great detective work dhannigan!
I wonder what the thinking is behind the random id generator on page load.
Thanks for sharing the hack. I too hate to hack a plugin because as we all know when the plugin gets an update the hack vanishs and we will be back to square one.
Now wouldn’t it be a dream if, in this scenario, we could create a “Child plugin”, like for themes.
My guess would be generating a random ID would help if you have multiple accordions on one page – resolves conflicting IDs. But, with the code above you shouldn’t have to mess with the random ID 🙂
I’m going to keep testing the plugin today, but it almost seems like users cant actually pass values to the accordion like it states you can. I’m not sure though.
Dan Just to let you know that
'heightStyle' => 'content'
I’ve created a copy of this plugin until this one is updated
you can download it here
Awesome! Well done fellas with this addition. I just recognized that a fixed height was being applied to each accordion. In my instance, it was using the height of the first accordion. In other people’s links, it wasn’t always the first item’s height.
I’m gonna e-mail the plugin author. Hopefully he’ll include this option in future updates.
Thank you for the fix! Also, the reminder about the comma prior. I found this solution in another thread and couldn’t figure out why it broke the plugin. Duh, I obviously need a break….
- The topic ‘Fixed accordions height ?’ is closed to new replies.