By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,252 Members | 1,684 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,252 IT Pros & Developers. It's quick & easy.

Dynamic equal height with jQuery

damir
P: 14
Hi everyone!

I have a problem with dynamic height. I've made an equal height function which basically works when it's called, but the problem is with jquery animations, to be more precise with slideDown function in combination with ajax.

The right side (see image below) is a place for comments, and after each submitted comment with ajax it's added with slideDown function. I don't know how to make that both section heights change their height dynamically during the slideDown animation.

Scheme:



Code:
Expand|Select|Wrap|Line Numbers
  1. function SetHeight()
  2. {  
  3.    var tallest = 0;  
  4.    $("#content > section").height('auto');
  5.  
  6.    if ($("section#left, section#right").size() > 1)
  7.    {
  8.       $("#content > section").each(function()
  9.       {
  10.          height = $(this).height();
  11.          if (height > tallest)
  12.             tallest  = height;
  13.       });  
  14.  
  15.       $("#content > section").height(tallest); 
  16.    }
  17. }
  18.  
  19. $(document).ready(function(){
  20.    SetHeight();
  21. }
  22.  
  23. $('form').submit(function(event){
  24.    event.preventDefault();
  25.    $('button[type=submit]').attr('disabled', 'disabled');
  26.  
  27.    $.post('/script/shift-comment',
  28.    {
  29.       shift: $('input[name=shift]').attr('value'),
  30.       message: $('textarea').val()
  31.    },
  32.    function(data)
  33.    {
  34.       $(data).insertBefore('#comment').hide().slideDown();
  35.       $('textarea').val('');
  36.    });     
  37. });
Mar 29 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.