mr.nothing
mr.nothing

Reputation: 5399

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!

Upvotes: 0

Views: 331

Answers (1)

stormdrain
stormdrain

Reputation: 7895

You probably do not have anid set on the button...

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:

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/

Upvotes: 1

Related Questions