PDA

View Full Version : [2.0a1 / 2.0b1][SOLVED] Cannot enable or disable a button.



FBergeron
18 Oct 2007, 12:57 AM
I have the following code :



var Test = function() {

var win, buttonToggleA, buttonToggleB, buttonA, buttonB;

return{
init: function() {
buttonToggleA = new Ext.Button( { text:'Toggle A', handler: Test.toggleButtonStateA } );
buttonToggleB = new Ext.Button( { text:'Toggle B', handler: Test.toggleButtonStateB } );
buttonA = new Ext.Button( { text:'A' } );
win = new Ext.Window( {
title: 'Test',
layout:'fit',
width:500,
height:300,
buttons: [ buttonToggleA, buttonToggleB, buttonA ]
});
buttonB = win.addButton( { text: 'B' } );
win.show(this);
},
toggleButtonStateA : function() {
buttonA.setDisabled( !buttonA.disabled );
},
toggleButtonStateB : function() {
buttonB.setDisabled( !buttonB.disabled );
}
};
}();
Test.init();


Clicking the button "Toggle A" should enable and disable the button A but it doesn't work.

However the button "Toggle B" works as expected.

It looks that depending on how you create the buttons, whether by using buttons: [ ] in the config or win.addButton( { } ); that the result is not the same. It looks like a bug to me.

Also, the width of the buttons A and B differs. I would have expected a similar size.

tryanDLS
18 Oct 2007, 9:29 AM
Are you still using the alpha build? If so, please try this with the beta1 build. I seem to remember a recent thread where Jack found an issue with adding buttons.

FBergeron
18 Oct 2007, 6:32 PM
The behavior is the same in beta1.

cyberwizzard
22 Oct 2007, 3:48 AM
I second that - I spend 2 hours looking for some error in my code and finally decided that it wasn't my fault.

I worked around the issue using this thread: http://extjs.com/forum/showthread.php?t=14754&highlight=button+enable

jack.slocum
22 Oct 2007, 2:08 PM
The buttons option in the window config or any Panel) is for button configs, not for button instances. The latest docs reflect that.

We may actually change it to allow passing in instances for the next release as it seems to be a common issue.

jack.slocum
22 Oct 2007, 2:17 PM
This has been added in SVN.