Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creates separate HTML for each of many identical menus. #17

Open
ke1g opened this issue May 7, 2013 · 0 comments
Open

Creates separate HTML for each of many identical menus. #17

ke1g opened this issue May 7, 2013 · 0 comments

Comments

@ke1g
Copy link

ke1g commented May 7, 2013

I have a set of run time defined divs that each have the same context menu (interspersed with items having a second menu, and one moving item with a third menu, so putting something on an outer container doesn't seem fruitful). As items come and go, I acquire an ever expanding set of identical hidden menus at the end of the body. I'd rather have just one (of each distinct menu).
Looking at the code, it seems that binding the same mouse event handler to multiple triggering elements would just work. The correct menu is known to the handler through closure, and the handler would still get the correct triggering element as "this".
[I'm working on an approach where the final binding step is abstracted into another function defined within the jQuery.fn.contextMenu call, and is thus closed on the correct event handler, and which takes, as an argument, the jQuery object on which to call .bind() or .on(). An additional option, or additional optional argument, or calling jQuery.fn.contextMenu on an empty jQuery object would cause the binding function to be returned instead of called. So I would call contextMenu with the (currently extra option) and save the returned function, later applying it to the elements that need that menu as they came into existence. Suggestions welcome.

Indeed, this approach seems to work, tested with Chrome.]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant