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

How to remain bottom the scroll bar using javascript/jquery?

Exequiel
100+
P: 287
My problem here is that the scroll bar is not staying in bottom, after loading the data using ajax the scroll bar still on top. but when i place the code for positioning the scroll bar at the bottom before doing the function see_message_toreply(deskid); it works, but after doing this function its not working. . can any body help me my problem?:)
Expand|Select|Wrap|Line Numbers
  1.  
  2. function save_reply(theuser, deskid)
  3. {
  4.     var reply = $("textarea[name=reply_fields]").val();
  5.  
  6.     if(reply!="")
  7.     {
  8.         //when i put it here it works!
  9.  
  10.         if(reply.length >= 10)
  11.         {
  12.  
  13.             $.ajax({
  14.                 type:'post',
  15.                 url:URL+"index.php/company/save_reply",
  16.                 data:{
  17.                     theuser:theuser,
  18.                     deskid:deskid,
  19.                     message_reply:reply
  20.                 },
  21.                 success: function(replyz)
  22.                 {
  23.                     if(replyz == 1)
  24.                     {
  25.                         see_message_toreply(deskid);
  26.                         $("textarea[name=reply_fields]").val('');
  27.  
  28.                         var div = $('#main_scrol_reply');
  29.                         div.delay(5000).scrollTop( div.get(0).scrollHeight );//scroll to bottom not work after loading the data, this is my problem
  30.                     }
  31.                 }
  32.             });
  33.         }
  34.         else
  35.         {
  36.             $('#pop_msg').fadeOut('fast').html("Reply too short.").removeAttr("class").attr('class','errormsg').fadeIn('fast').delay(5000).fadeOut('fast').draggable({revert: false,containment: 'body',handle:'#pop_msg'});    
  37.         }
  38.     }
  39. }
  40.  
  41.  
Aug 15 '13 #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.