Setting cursor at end of added text to Textarea

I'm using a textarea as a sort of log console in a page, which receives data to be added at the end of the current text. When i add more text to the textarea, how can i make it so it scrolls down as new text is added?

Tagged:

Comments

  • Hi,

    You need to work with the Textarea's input node to manipulate scroll position and cursor:

    var log = $$("log");
    var pos = log.getValue().length;
    var height = log.getInputNode().scrollHeight;
    
    //set cursor in the end
    webix.html.setSelectionRange(log.getInputNode(), pos);
    //show the input end
    $$("log").getInputNode().scrollTop = height;
    

    Check the following snippet, please: http://webix.com/snippet/0680e4ab

  • Sorry,I did as you said but I have this error: Uncaught RangeError: Maximum call stack size exceeded.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!