Why can't I turn off this XUL menu item?

I am at my end, and this is probably something really simple. I basically have this code:

var menuitem = document.getElementById('mymenuitem');
alert(menuitem);
alert(varImChecking == null);
menuitem.setAttribute('disabled', (varImChecking == null) ? 'true' : 'false');

It should disable the menu item "mymenuitem", but has no effect. When the warning starts, they say: "[XulElement Object]”, followed by "true". I know that getElementById selects the correct menuitem element because onclick bindings to the menuitem variable work.

Some alternatives I've tried:

menuitem.setAttribute('disabled', (varImChecking == null));
menuitem.disabled = (varImChecking == null);

So why does setAttribute not matter? It does not even obscure the menu item. Is there any other way I have to do this?

Edit: Forgotten, the console does not display warnings or errors.

+3
6

, , , . , , , .xul . - .

, menuitem .xul , javascript. , :

var menuitem = document.getElementById('mypopupitem').appendChild(document.createElement('menuitem'));
menuitem.setAttribute('disabled', 'true'); // Works.
menuitem.removeAttribute('disabled'); // Also works.

- , / XUL, ?

:. , . , XUL .

, , .., , . Grrr.. .

, document.getElementById('menuitem') XUL, . , onclick, , , , ( ?). , setAttribute ('label', 'changed') , , , , , .

, , . !

+1

: , , "disabled" . menuitem oncommand, .

+2

, setAttribute "true" / "false", .

, . menuitem.setAttribute('disabled', 'true'); ? - , . - , ?

. , . , bugzilla, , disabled = false Linux. Mozilla - , , .

, , , , :

var menuitem = document.getElementById('mymenuitem');
alert(menuitem);
alert(varImChecking == null);
if(null==varImChecking){
   menuitem.setAttribute('disabled', 'true');
}else{
   menuitem.removeAttribute('disabled');
}
+1

. . , disabled menu, - true false. , menupopup , e.i. onpopupshown. .

. xD , .

BTW:

  • xul firebug
+1

, :

var menuitem = document.getElementById('mymenuitem');
alert(menuitem);
alert(varImChecking == null);
menuitem.setAttribute('disabled', (varImChecking == null) ? true : false);

true false, "true" "false"

0

, . onpopupshowing / , , . , overlay.xul

< popup onpopupshowing = "isAssertTextEnabled (this)" id = "contentAreaContextMenu" >
  < menuitem id =" context-recorderpopup "label =" "
            Accesskey =
" "            InsertAfter =" - "            OnCommand =" onAssertionMenu () "            / >
 </ >

please let me know if i miss something.

Thanks, Winnie

0
source

Source: https://habr.com/ru/post/1706930/


All Articles