繁体   English   中英

Sencha Touch 2:

[英]Sencha Touch 2:

我收到了Uncaught TypeError:无法调用未定义的方法“ focus”
发生在

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

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

尝试组件查询。

Ext.ComponentQuery.query(“#myinput”)。focus();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM