XUL: create menu items dynamically and set "selected" attr

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2010-05-28T06:17:00Z Indexed on 2010/05/28 6:21 UTC
Read the original article Hit count: 176

Filed under:
|
|

I have a firefox extension Options pref panel, where I should dynamically create menu items and select particular item to be current.

here is the XUL file part

<menulist id="rss_service_combo">
    <menupopup id="rss_service_menu"/>
</menulist>

Then in load event of the pref panel, using js I append menuitem elements into menupop. This is working fine. The only problem is that even if I set the selected element the item is not selected and combo box is initially empty.

The only way is working at the moment is if I manually add those menuitems into XUL file and set selected attribute, but I need to do it dynamically.

© Stack Overflow or respective owner

Related posts about xul

Related posts about firefox-extension