bfschott
bfschott

Reputation: 311

how to reset max height of element on window resize

I'm trying to reset the max height of a <p class="product_description"> in a set of responsive bootstrap columns. However, this code only seems to work on initial document load and not the resize event. What am I missing?

function DoEqualSizer(myclass) {
    var heights = $(myclass).map(function() {
        $(this).height('auto');
        return $(this).height();
    }).get(),
    maxHeight = Math.max.apply(null, heights);
    $(myclass).height(maxHeight);
};

function EqualSizer(myclass) {
    $(document).ready(DoEqualSizer(myclass));
    window.addEventListener('resize', DoEqualSizer(myclass));
};

EqualSizer('.product_description');

Upvotes: 0

Views: 330

Answers (1)

Michal Hosala
Michal Hosala

Reputation: 5707

Try to modify it as:

function EqualSizer(myclass) {
    $(document).ready(DoEqualSizer(myclass));
    window.addEventListener('resize', function() { DoEqualSizer(myclass); });
};

Upvotes: 1

Related Questions