PDA

View Full Version : disabled propery vs disable & enable function



zenox
8 Aug 2007, 1:52 PM
Hey,
Here is an issue I noticed and figured I would report:
I have a tree with a context menu. Depending on which node is chosen I disable/enable certain nodes. The code was like this:



myTree.on ( 'contextmenu', function (node) {node.select();toggleMenu(node.directory);contextMenu.show(node.ui.getEl());}, this );


Where my tree is 'myTree' my context menu is 'contextMenu'
This was my origional toggleMenu function


toggleMenu:function(dir){
ndMenu.disabled = !dir;
nfMenu.disabled = !dir;
}


Now with this code, my menu items css was not changing properly. The items would stay disabled.

I changed the function to be this:


toggleMenu:function(dir){
if ( !dir ){
ndMenu.disable();
nfMenu.disable();}
else{
ndMenu.enable();
nfMenu.enable();
}


And everything is working properly. Hopefully this post will help someone out in the future.
If you have any questions feel free to ask away.

zenox
8 Aug 2007, 2:53 PM
This was when im using:
Ext JS Library 1.0.1

jack.slocum
8 Aug 2007, 3:34 PM
disabled is a property. In JavaScript, changing a property can't trigger an action, only a function can.