asyndrige
asyndrige

Reputation: 592

Listener for resize event

Using bootstrap collapsing menu and need to add css property to another div, when menu is collapsed. .nav-collapse inline height value changes, but the event listener doesnt work. So whats the problem? Or is there another way to make, what I want?

$('.nav-collapse').resize(function() {
            var height = $('.nav-collapse').height();
            $('.custom-class').css('margin-top', height);
        })

Upvotes: 0

Views: 64

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1074108

Elements don't have a resize event, just window.

You'll have to apply the margin-top another way, there just isn't an event to hook here. If the collapsing menu gets a class added to it or similar, you can probably use that if the other element is either a descendant or a sibling. (If it's neither, it gets really hard.)

Or you could hook the event(s) that close the collapsing menu, and handle the margin-top there (either immediately, or if the collapse is animated, after a delay).

Upvotes: 1

Related Questions