Push down footer or other blocks when opening accordion
PermalinkIf I use normal bootstrap coded areas or embedded layouts, accordions expand nicely and push the footer or other blocks down.
Is the problem in the concrete 5 accordion or the masonry script?
<script> var $grid = $('.grid').imagesLoaded( function() { // init Isotope var $grid = $('.grid').isotope({ itemSelector: '.grid-item', layoutMode: 'masonry', masonry: { columnWidth: '.grid-sizer'}, }); $grid.imagesLoaded().progress( function() {$grid.isotope('layout');}); }); </script>
Using the class .collapse helps but block are alined wrong.
Any hints?
Thanks in advance
Stef

Page is at:http://www.blink-design.ch/apo/index.php/test/testen-impfen-masonry...
which is a stage server of the agency I work for. I managed to get the footer and other block to push down with a script I found from the creator of Isotope, David Desandro.
This script I added in the footer works fine, but unfortunately, when opening an accordion it closes any other open accordion. There's no way of opening all accordions to stay open. I guess I have to experiment a little to have the desired effect.
Maybe it's just a small thing in the scipt, but since I'm weak in JS I'd be happy to get some hints.
<script> var $grid = $('.grid'); $grid.on( 'click', '.header', function( event ) { var $title = $( event.currentTarget ); var $gridItem = $title.parents('.grid-item'); var isOpen = $gridItem.hasClass('open'); $grid.find('.open').removeClass('open') .find('.content').slideUp( 'fast', layoutIsotope ); if ( !isOpen ) { $gridItem.addClass('open') .find('.content').slideDown( 'fast', layoutIsotope ); } }); function layoutIsotope() { $grid.isotope('layout');
Thanks
Stef
<script> var $grid = $('.grid'); $grid.on( 'click', '.header', function( event ) { var $title = $( event.currentTarget ); var $gridItem = $title.parents('.grid-item'); var isOpen = $gridItem.hasClass('open'); if ( !isOpen ) { $gridItem.addClass('open') .find('.content').slideDown( 'fast', layoutIsotope ); } else { $gridItem.removeClass('open') .find('.content').slideUp( 'fast', layoutIsotope ); } }); function layoutIsotope() {
That way if the accordion is triggered and it's not yet open it will be opened, and if it's triggered and it is already opened it will be closed, but the rest of the accordion items won't be affected either way.
I try to inlude it in the JS of the accordion to see.
Regards from Zurich, 28°F
<script> var $grid = $('.grid'); $grid.on( 'click', '.header', function( event ) { event.preventDefault(); event.stopPropagation(); var $title = $( event.currentTarget ); var $gridItem = $title.closest('.grid-item'); var isOpen = $gridItem.hasClass('open'); if ( !isOpen ) { $gridItem.addClass('open') .find('.content').slideDown( 'fast', layoutIsotope ); } else { $gridItem.removeClass('open') .find('.content').slideUp( 'fast', layoutIsotope ); }
This time, on first click, it opens accordion wihich dissapears und block underneath. On second click it opens properly and moves to availabe space.
In an older Edge browser it won't open at all (not to worry about-it's just info). The live site at apothekeschaffhauserplatz.ch works now without isotope since there are only three boxes.
If I have the working code, I will publish it here.
Thank you again for helping.
Stef