1

我收到 Uncaught TypeError: Cannot call method 'focus' of undefined
发生在

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?

它仅适用于第一次打开的消息框。

更新:以下是我的核心代码。

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();
4

2 回答 2

0

这意味着Ext.getCmp('myinput')找不到您的领域。因此,可能在您调用该函数时该字段尚未创建,或者您在 id 中有一个类型,或者可能,根据您的描述,您第二次调用它时该字段已被销毁......如果没有周围的代码,就不可能肯定地说。

于 2013-06-24T09:19:45.807 回答
0

尝试组件查询。

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

于 2013-06-24T14:41:30.987 回答