简体   繁体   English

extjs对加载的窗口组件执行一些操作

[英]extjs do some action with window components on it's load

I'm trying to disable a button on window when this window pops up but whatever handlers I tried to apply, window in not poped up and just spits out that "undefined" staff to me. 我试图在弹出该窗口时禁用窗口上的按钮,但是无论我尝试应用什么处理程序,都不会弹出窗口,只是向我吐出“未定义”的人员。 For example I tried: 例如,我尝试过:

window.onload = Ext.getCmp('buttonId').disable();

and it returns me this in console: 并在控制台中将其返回给我:

Uncaught TypeError: Cannot call method 'disable' of undefined  

Thanks everyone in advance! 提前谢谢大家!

You probably do not have an id set on the button... 您可能没有在按钮上设置id

Why don't you disable the button directly? 为什么不直接禁用按钮?

Ext.create('Ext.Button', {
    text: 'Disabled button',
    disabled:true
});

If you have an id on there, it works: 如果您在那上面有一个id ,它可以工作:

Ext.create('Ext.Button', {
    text: 'Dynamically disabled Button',
    id:'dynamicBtn',
    renderTo: Ext.getBody(),
    handler: function() {
        alert('You clicked the button!');
    }
});

Ext.application({
    name: 'MyApp',
    launch: function () {
        Ext.getCmp('dynamicBtn').disable();
    },
});

http://jsfiddle.net/4fPSf/ http://jsfiddle.net/4fPSf/

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

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