Problem with android and jumping with <input textarea (JS)

we have a problem with devices posting comments in the news form with google chrome. If the news is just one everything works fine when you press enter with your phone, but when there are several news and when you press enter just start jumping to the latest news and it only works then. I think the problem is in javascript, so i want to ask you for help. Thanks.

This is javascript;

newsReply = function(event, id, item) {
    if(event.keyCode == 13 && event.shiftKey == 0){
        var content = $(item).val();
        var replyTo = id;
        if (/^\s+$/.test(content) || content == ''){
            return false;
        }
        if(content.length > 1000){
            alert("text is too long");
        }
        else {
            $(item).val('');
            if(repNews == 0){
                repNews = 1;
                $.ajax({
                    url: "system/action_news.php",
                    type: "post",
                    cache: false,
                    dataType: 'json',
                    data: {
                        content: content,
                        reply_news: replyTo,
                        token: utk
                    },
                    success: function(response){
                        if(response.code == 1) {
                            $('.ncmtbox'+replyTo).prepend(response.data);
                            nrepCount(id, response.total);
                            repNews = 0;
                        }
                        else {
                            repNews = 0;
                            return false;
                        }
                    },
                    error: function(){
                        repNews = 0;
                        return false;
                    }
                });
            }
            else {
                return false;
            }
        }
    }
    else {
        return false;
    }
}

this is our html;

HTML:

 <div class="tpad10 reply_post">
            <input onkeydown="newsReply(event, <?php echo $boom['id']; ?>, this);" maxlength="500" placeholder="<?php echo $lang['comment_here']; ?>" class="add_comment full_input">
        </div>

Hi @JamesH12, welcome to the forum.

There is nothing that stands out in your code, that I can see.

It’s hard to get a picture of what your problem is. Does it relate to $('.ncmtbox'+replyTo).prepend(response.data); and the use of prepend? I don’t know.

Is there some way you could supply some screen grabs, to illustrate the issue? Or maybe a demo of some sort?

In the meantime maybe someone else here has a better grasp of the problem.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.