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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Exequiel
    Contributor
    • Jul 2012
    • 288

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

    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_tor eply(deskid); it works, but after doing this function its not working. . can any body help me my problem?:)
    Code:
    function save_reply(theuser, deskid)
    {
    	var reply = $("textarea[name=reply_fields]").val();
    	
    	if(reply!="")
    	{
    		//when i put it here it works!
    		
    		if(reply.length >= 10)
    		{
    			
    			$.ajax({
    				type:'post',
    				url:URL+"index.php/company/save_reply",
    				data:{
    					theuser:theuser,
    					deskid:deskid,
    					message_reply:reply
    				},
    				success: function(replyz)
    				{
    					if(replyz == 1)
    					{
    						see_message_toreply(deskid);
    						$("textarea[name=reply_fields]").val('');
    						
    						var div = $('#main_scrol_reply');
    						div.delay(5000).scrollTop( div.get(0).scrollHeight );//scroll to bottom not work after loading the data, this is my problem
    					}
    				}
    			});
    		}
    		else
    		{
    			$('#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'});	
    		}
    	}
    }
Working...