开发者

A Javascript Context Menu?

Im creating a web app that will need context menus when the user right clicks and have stumbled upon this one which i like very much. Im having a problem in that when i assign two div elements two different menus, the same menu appears for both. For example the code below creates two div elements, puts them onto the page and then assigns a seperate context menu for each of them.

this.leftDiv = do开发者_如何学运维cument.createElement("div");
this.leftDiv.id = "Left_DIV";
document.body.appendChild(this.leftDiv);
$("#" + this.leftDiv.id).contextmenu(left_Options);
.........
this.rightDiv = document.createElement("div");
this.rightDiv.id = "Right_DIV";
document.body.appendChild(this.rightDiv);
$("#" + this.rightDiv.id).contextmenu(right_Options);

Now when the app is loaded in the browser, both of the divs have the left_Options menu system.

Would anyone be able to recommend a good javascript context menu that is easy to use?

Cheers.


Based on the site that you linked to, it looks as if one set of options is applied to all of the 'div' elements. It presumes that you want to have similar options for all of your context menus.

In order to customize each individual menu, you add an 'onShow' option that can run a function enable/disable some items. I'm not sure how flexible this is for completely different menus.

A quick search turned up this: http://www.trendskitchens.co.nz/jquery/contextmenu/ It claims to support multiple menus on a single page, so perhaps that's what you're looking for. I have not used it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜