lundi 27 juin 2016

Sometimes the div doesn't get scrolledTop

So I'm trying to create my own chat with support to offline messages. I can use it already, but sometimes when I send a message, the scroll doesn't move as it should, and if I want to see the message I just sent I have to scroll down a little bit. It keeps having different behavior everytime and that's what bothers me. this is the script responsible for the scrolling whenever I send a message

success: function () {
                //do something with response
                var url = '/Chat/ReturnTeacherNewMessages?Student_id=' + '@ViewBag.Student_id';
                $('#user_content').load(url);
                $('#MSG').val("");
                $.ajax({
                    success: function () {
                        var wtf = $('#user_content');
                        height = wtf[0].scrollHeight;
                        wtf.scrollTop(height);
                    }
                })
            }

Aucun commentaire:

Enregistrer un commentaire