tags:

views:

22

answers:

1

Hi

I have a really weird bug and cant figure out why things are not working consistently.

I have two content divs, eaither one of them could be shorter than the other.

I have a script that checks to see which one is taller, and then I make the other equal it.

It works when i click around within the site, so say I click on "Next" or click on a page link direcly, the script works like it should.

If i go to the page directly via my browser address bar, or if i refresh the page, it doesn't do it. Why on earth?!

here is the script:

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

var getCreditsHeight = $("#project_credits").outerHeight()-30;
var getDescriptionHeight = $("#project_description").outerHeight()-30;

if ( getCreditsHeight > getDescriptionHeight ) {
    $("div#project_description").height(getCreditsHeight);
} else {
    $("div#project_credits").height(getDescriptionHeight);
};
}); 
}); 

As you can see it's on document ready.

If I load a new page, then click onto the page in question for the first time, it also does it. but if i go back to the homepage and then click in again, it works...

Thanks, Marc

+2  A: 

can u try removing the jQuery function but you have wrapped around document ready? so its like this:

$(document).ready(function(){   

var getCreditsHeight = $("#project_credits").outerHeight()-30;
var getDescriptionHeight = $("#project_description").outerHeight()-30;

if ( getCreditsHeight > getDescriptionHeight ) {
    $("div#project_description").height(getCreditsHeight);
} else {
    $("div#project_credits").height(getDescriptionHeight);
};
}); 
Moin Zaman
this was my thought as well.. no reason for that extra wrapping..
KP
What the...OK, so why was it causing problems?I have a LOT of jQuery in this file that is all doing everything totally 100%... Do you have any idea why it's affecting just this and not the other stuff?
RGBK