ExtJS component get the different position from afterrender and focus event?

285 views Asked by At

Hi I tried to get component position but I found the getXY() will show diffrent position in different events.

like this sample, fiddle

init: function() {
    var me = this;

    me.control({
        'textfield[itemId=field]': {
            change: me.changeField,
            focus: me.focusField,
            afterrender: me.afterRenderField
        }

    });

},

focusField: function(field, event) {
    console.log(field.getXY());
},

changeField: function(field, newValue, oldValue) {
    console.log(field.getXY());
},

afterRenderField: function(field) {
    console.log(field.getXY());
}

I think the correct position is in focus and change events. Why afterrender is different?

I want to do something after the component is rendered so I need to get the correct position.

1

There are 1 answers

1
aviram83 On BEST ANSWER

you can use the event boxready

the reason for the difference is event the object is rendered it's not lay out yet.