I am creating a task manager for my app and I'm trying to calculate the height of the widget then do something if it meets requirements. Basically I I want to get the height of the window minus another figure to get the max-height (a min-height is already set) of the task widget. Then I want to dynamically get the actual height of the div and if it equals the max height than I want to change a few css properties. I'm using jquery 1.5.2 to do this. Here is what I have...
$(document).ready(function() {
//Get the height for #tasks
var tH = Math.round($(window).height() - 463);
$('#tasks').css('height', tH); //Make it the max height
var ti = Math.round($("#tasks").height()); //Get actual height of #tasks
if(tH==ti){ // If #tasks actual height is equal to the max-height than do...
//alert('true');
$('.taskItems').css('width', '172px');
$('.tT, .tD').css('width', '135px');
console.debug(ti + ' ' + tH);
}else{
alert(tH + ' ' + ti);
console.debug(ti + ' ' + tH);
}
});
This works great as long as the "alert('true')" fires off first and "max-height" is change to "height".
When the alert is commented out, the if statement stops working.
When the
$("#tasks").css('height', tH) is changed to $("#tasks").css('max-height', tH)
the values are insanely off. Example: 78/130. The css is as follows...
#tasks {
border:1px solid #D1D1D1;
border-top:none;
color:rgb(82,124,149);
display:inline-block;
font-size:12px;
margin:0px 0px 0px 1px;
overflow:auto;
width:194px;
}
Any help would be appreciated. Thanks in advance.