PDA

View Full Version : How to disabled button



edwardking
9 Aug 2010, 4:49 AM
I have two buttons under Ext.Window,such as "submit" button and "reset" button,when I click submit button,I want to disabled "submit",I know I should set disabled true,so I use following statement to disable button

win.getComponent('loginForm').form.id1.disabled=true;

But when I run, it raise following javascript error:
win.getComponet(...).form.id1 is null or not an object

My code is follows,how to correct my code? Thanks



var win=new Ext.Window({
el:'hello-win',
layout:'fit',
animateTarget:document.body,
items:
loginForm,
buttons:[{
text:'Submit',
id:'id1',
handler:function(){
if(win.getComponent('loginForm').form.isValid()){
win.getComponent('loginForm').form.submit({
url:'test.do' (http://www.sencha.com/forum/'test.do'),
waitTitle:'waiting',
method:'POST',
waitMsg:'waiting while login.....',
success:function(form,action){
Ext.Msg.alert('Success',action.result.message);
win.getComponent('loginForm').form.id1.disabled=true;
},
failure:function(form,action){
Ext.Msg.alert('Fail',action.result.message);
refreshcode();
}
});
}
}
},{
text:'reset',
}]
});

mankz
9 Aug 2010, 11:54 AM
Instead of



win.getComponent('loginForm').form.id1.disabled=true;


Try:


Ext.getCmp('id1').setDisabled(true);