Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think I finally figured this out. The problem is that I had the menuitem I was trying to edit was <strong>hardcoded inside a .xul file</strong>. For whatever reason, this made it impossible to change the disabled or hidden attributes.</p> <p>So I removed the menuitem from the .xul file and <strong>dynamically created it in the javascript</strong> instead. Now it works exactly as expected:</p> <pre><code>var menuitem = document.getElementById('mypopupitem').appendChild(document.createElement('menuitem')); menuitem.setAttribute('disabled', 'true'); // Works. menuitem.removeAttribute('disabled'); // Also works. </code></pre> <p>Does anyone know, is this a feature/quirk of XUL, or am I just doing it wrong?</p> <p><strong>UPDATE:</strong> As many comments have pointed out, the above is not correct. You absolutely can change the disabled attribute on an item hard coded in a XUL file.</p> <p>After much more debugging, paring the problem down to its core elements, pulling hair, etc, it turned out to be.... a typo. Grrr.. Sorry.</p> <p>It turns out my document.getElementById('menuitem') was grabbing the XUL element, not the element. The fact that the onclick method seemed to be firing correctly seems to have been thanks to event bubbling (I guess?). I still have no idea why setAttribute('label', 'changed') worked when I tried that, but unfortunately, in the frenzy of debugging, I don't have that version to check again.</p> <p>Anyway, it's working now, without having to dynamically create the menuitem. Thanks for all the help!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload