If you set the "lazyload" configuration property to
"true" for your ContextMenu, then its contents will
not get created and the menu itself will not be
rendered until the "contextmenu" event is actually
That said, if you're creating a ~1000 elements with
unique context menus, then, yes it would be better to
reuse a single ContextMenu instance and reuse it. You
can subscribe to your context menu's "showEvent" and
use the "contextEventTarget" to determine what child
node was the actual target of the "contextmenu" event
that triggered the display of the menu. You can then
use that target element to determine what content you
need to add or remove from the menu.
--- Michael Winston <email@example.com> wrote:
> Let's say I have 1000 different nodes and each one
> could have a
> custom contextual menu (using YUI Menu, of course).
> I'm a little
> worried about the performance efficiency of building
> 1000 individual
> contextmenus (lazyloaded or not) on the chance a
> user might actually
> want to use one or two of them. This is especially
> true since some
> number of the menus might need to be built with AJAX
> So what I'd like to do is just attach an
> 'oncontextmenu' listener to
> those 1000 nodes that will dynamically build,
> render, and override
> the browser's contextmenu.
> Is this possible and, if so, how?
> If not, it would be great to know that it's