Results 1 to 2 of 2

Thread: Textareafield scrollHeight not updated

  1. #1
    Sencha User
    Join Date
    Aug 2012
    Location
    Zurich
    Posts
    5
    Vote Rating
    0
      0  

    Default Textareafield scrollHeight not updated

    Hi all,

    I'm using some textarefields and I want to resize them when the content fills. There are several examples like this:
    http://stackoverflow.com/questions/9...n-sencha-touch

    In short, the code is
    keyup: function(field) {

    var TEXTAREA_LINE_HEIGHT = 20;
    var textarea = field.element.dom;
    var newHeight = textarea.scrollHeight;
    var currentHeight = textarea.clientHeight;

    console.log('newHeight1 = ' + newHeight + ' currentHeight ' + currentHeight);
    if (newHeight > currentHeight) {
    textarea.style.height = newHeight + 5 * TEXTAREA_LINE_HEIGHT + 'px';
    }
    }
    The problem is that .element.dom.scrollHeight always has the same value as field.element.dom.clientHeight.

    Anyone has experienced this?
    Thanks a lot!

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,551
    Answers
    3931
    Vote Rating
    1271
      0  

    Default

    Ran this code on my iPhone using ST 2.1.0 RC1 and the scrollHeight is different than the clientHeight:

    Code:
    Ext.Viewport.add({
        xtype : 'formpanel',
        items : [
            {
                xtype : 'textareafield'
            },
            {
                xtype   : 'button',
                text    : 'View',
                handler : function(btn) {
                    var form         = btn.up('formpanel'),
                        field        = form.down('textareafield'),
                        el           = field.getComponent().input,
                        scrollHeight = el.dom.scrollHeight,
                        clientHeight = el.dom.clientHeight;
    
                    alert(scrollHeight + ' - ' + clientHeight);
                }
            }
        ]
    });
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •