I analyzed your problem in more detail today. I'm sorry it took so long for the right solution... Now, here we go. Define the menu like this:
<ul id="menu">
<li id="context-menu">
The label doesn't matter
<ul>
<li>... context menu</li>
<li>... items</li>
</ul>
</li>
</ul>
So note that I assigned an ID to the LI which holds the context menu contents. Now, remember a reference to the DynarchMenu object when creating it:
var menu = DynarchMenu.setup("menu", { context: true });Now we need to create a dynamic element and assign the context menu to it:
var div = document.createElement("div");
...
document.body.appendChild(div);
// this does it:
DynarchMenu.setupContext(div, menu.items["context-menu"]);So there is actually an API for that :-) I'm just sorry I forgot about it in the first place, I could have helped you faster. To the “setupContext” function you need to pass a reference to the HTML element that should get a context menu and the item that holds the context menu--as you can see we can easily retrieve that using the “menu.items” hash, assuming we gave it an ID and have kept a reference to the DynarchMenu object.
Hope this helps.