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

Menu content is not rebuild when right-click is triggered after the first time #104

Closed
xyzxyz442 opened this issue Jan 17, 2013 · 4 comments

Comments

@xyzxyz442
Copy link

right-click to show context menu then move to other position then right-click again, content is not rebuild. But if you left-click then right-click it rebuild the content. So, it you want some kind like right-click on specific element with specific content menu. It has to left-click then right-click.

to illustrate the issue: http://jsfiddle.net/xyzxyz442/Zhyr3/5/

@rodneyrehm
Copy link
Contributor

I see the problem. This was initially thought to improve things. "Quick Fix":

$.contextMenu.handle.layerClick = function() {
  var $this = $(this),
    root = $this.data('contextMenuRoot');
    root.$menu.trigger('contextmenu:hide');
};

this disables the "repositioning" of an already open menu. At some point, this (obviously) needs to become a configuration flag.

@xyzxyz442
Copy link
Author

"repositioning" is working fine. I think its problem is that it only update the position. As I try to edit you code, before this "root.position.call(root.$trigger, root, x, y);" in layerClick is invoke. It should some how rebuild the content like you did in "contextMenu:show" which call custom "build" function and set the opt to the contextMenu or how to call this function: "op.update.call($trigger, opt);" as you said that this to update or create context menu

@rodneyrehm
Copy link
Contributor

Well, no. If a menu is open and you left-/right-click on the same element (or its children) the menu should not be rebuilt, just repositioned. At least that was the original idea, seeing that a build() menu could be doing an Ajax call to find out which items to show. Thinking about that, build() is currently missing a callback to allow that asynchronous behavior.

I don't want to give up on this idea just yet.

@rodneyrehm
Copy link
Contributor

I have added the reposition flag to prevent this from happening to you. Since you are detecting the node that was clicked on from within your build function (rather than simply defining multiple context menus by using distinct selectors [if at all possible in this case]), there is no other way than to prevent this from happening.

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

3 participants