Skip to content
New issue

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

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

Already on GitHub? # to your account

Feature request: being able to manually trigger contextMenu update #555

Closed
dwitvliet opened this issue Jul 31, 2017 · 4 comments
Closed

Comments

@dwitvliet
Copy link

Hi,
There are various triggers for manually manipulating the contextMenu. However, there is currently no easy way to trigger an update of the elements in the contextMenu. It would be great for plugins to be able to update the elements, e.g. with $(".some-selector").contextMenu("update");.

@dwitvliet dwitvliet changed the title Feature request: being able to manually update contextMenu Feature request: being able to manually trigger contextMenu update Jul 31, 2017
@bbrala
Copy link
Member

bbrala commented Jul 31, 2017

When using the build option, the menu is built every time you open the menu, wouldn't that fix your problem?

https://swisnl.github.io/jQuery-contextMenu/demo/dynamic-create.html

@dwitvliet
Copy link
Author

dwitvliet commented Jul 31, 2017

Hi, thank you for the quick response!
Sorry, I wasn't specific enough in my original post. I am looking for a function that allows updating the contextMenu elements while the contextMenu is visible (so the visible and disabled functions are run again). The build option would require the menu to be hidden and then be rebuilt in order to update the menu.

@hybridwebdev
Copy link

hybridwebdev commented Aug 26, 2017

First off, thanks for such an amazing plugin. To add to this topic, I believe an update option would be wonderful, as I've noticed that if you do something
div class='something' Stuff and thangs. div

And then bind a context menu on the something class, all works well. However, this only occurs if the element is already in the dom. For dynamically created elements, or for elements that may get moved in and out of the dom via ajax calls, the context menu no longer works as the element was in the dom during the initial context menu call.

I've been through the documentation of the plugin, and as far as I can tell no method for this desired behavior works. Perhaps I'm just missing something, but it seems like a way to update element binds is the way to go.

bbrala added a commit that referenced this issue Sep 8, 2017
@bbrala
Copy link
Member

bbrala commented Sep 8, 2017

I've added a feature to support updating the menu. See: http://swisnl.github.io/jQuery-contextMenu/docs.html#update-contextmenu-state

@bbrala bbrala closed this as completed Sep 8, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants