question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Height issues with ajax

See original GitHub issue

Hi,

I’m using matchHeight() on a WordPress site, and its working fine on initial render. But I’m using Ajax Load More to load more posts, using jQuery’s ajaxComplete() to update the height on loaded posts. It’s working fine on the first load, but on the second load the heights are set to high (should be around 300px, gets set to around 500px).

Here is my JS:

    jQuery.noConflict();
    jQuery(document).ready(function($){

        $(function() {
            $('#employees .person').matchHeight();
        });

        $( document ).ajaxComplete(function() {
            $.fn.matchHeight._apply('#employees .person')
            $.fn.matchHeight._maintainScroll = true;
        }); 

    });

And ideas?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
gnistdesigncommented, Sep 11, 2014

Alas, no – that didn’t help.

After much trying, the best I’ve been able to come up with is this:

       $( document ).ajaxComplete(function() {
            $.when('AjaxLoadMore.loadPosts').done(function() {
                setTimeout(function() {
                    $.fn.matchHeight._apply('#employees .person');
                }, 300);
            });
        }); 

ALM uses a slide (or fade) effect that takes 300 ms. If I don’t put in the delay, the heights are set way to high. And the page «jumps» when heights are set, no matter if I have the delay or not.

2reactions
liabrucommented, Sep 10, 2014

I think you’re maybe better doing something more like:

jQuery(document).ready(function($){

    $(function() {
        $.fn.matchHeight._maintainScroll = true;
        $('#employees .person').matchHeight();
    });

    $( document ).ajaxComplete(function() {
        $('#employees .person')
            .matchHeight('remove')
            .matchHeight();
    }); 

});

Does that help?

Read more comments on GitHub >

github_iconTop Results From Across the Web

JQuery Accordion Ajax Height issue - Stack Overflow
I know it is caused by the ajax and dynamically adding the accordion because if I add my own headings and divs inside...
Read more >
Page height issue in AJAX framework after switching to ...
iView added, the height of the page appears to default to Height Type of Fixed and Fixed Height of 80. We have changed...
Read more >
Height Issue With UseStaticHeaders in UI for ASP.NET AJAX
Hello Jon, When the height of a div element is set with percentage, the height will be calculated based on the parent element...
Read more >
Cleverly set height and proportions of a responsive HTML ...
Setting an explicit height of a container within responsive layouts is less common and may lead to errors when loading the AJAX-ZOOM viewer ......
Read more >
Row height causes problem on ajax and showing row with ...
The impact is that the "Showing" bloc show "Showing 1 to 20 of 21,254 entries (filtered from 455 total entries)" when only 10...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found