1
votes

I'm getting Uncaught TypeError: Cannot call method 'focus' of undefined
happens when

Ext.Msg.prompt with #myinput closed and then opened **again**.
Ext.getCmp('myinput').focus(); works fine for the first time only. How to set the cursor into `myinput` always?

It works for the first time message box opened only.

Update: below is my core code.

Ext.Msg.prompt('',
    'Some text description', 
    function(btn, text) {

    },
    this,
    false,
    null,
    { placeHolder: 'Please enter some text here', xtype: 'numberfield', id: 'myinput' }
);
Ext.getCmp('myinput').focus();
2

2 Answers

0
votes

That means that Ext.getCmp('myinput') doesn't find your field. So maybe the field is not created yet at the time you call the function, or maybe you've got a type in the id, or probably, given your description, that the second time you call it the field has been destroyed... Impossible to say for sure without the surrounding code.

0
votes

Try a component query.

Ext.ComponentQuery.query("#myinput").focus();