Context Menu on multiple same name zones

Hi,

I’ve spent a lot of time trying to figure this out, and I have a suitable solution finally, but not sure if it is the best. Maybe someone can help.

What I’ve created is a chat room, and I needed a right-click context menu on the usernames that show up in the chat. So obviously if a user has posted several messages, the context zone would all be the same ID, which doesn’t work. So what I’ve done is make the id instead the username + current time in seconds. That makes them all unique and it works. However, I could be creating potentially a thousand or more context zones in a day. Could that be a problem? Do you know of a better solution?

Another issue is for each line I’ve got a Div container surrounding the whole line of text, then the username is wrapped in just a that has the contextZone ID. When I right-click on the username, the context menu is over to the right. It’s almost as if it wants be outside of the surrounding Div. If I remove the surrounding Div, the context menu doesn’t work at all. Should it not be able to bind to a with an ID?

So is my method in the first paragraph ok to do with the unique IDs?

And how do I get the context menu drop right below a inside a surround Div?

Thanks,
Max

Hi

there is a possibility to attach context menu to the common parent, then check if matched element is that one with user name by checking window event’s target, i.e.

[code]


user-1 name
user-1 comment

user-N name
user-N comment
[/code] [code] myMenu.addContextZone("mainParent"); myMenu.attachEvent("onBeforeContextMenu", function(ctxId, ev){ if (ctxId == "mainParent") { // in case of single menu for several zones if (ev.target.className == "css_user") { // user name clicked // do stuff, change avail menu items return true; } else if (ev.target.className == "css_comment") { // comment clicked // do stuff, change avail menu items return true; } } return false; // do not show menu otherwise });[/code]