Skip to content
This repository was archived by the owner on Aug 14, 2021. It is now read-only.

setEntry does not work with submenus #80

Closed
ghost opened this issue Nov 6, 2014 · 4 comments
Closed

setEntry does not work with submenus #80

ghost opened this issue Nov 6, 2014 · 4 comments

Comments

@ghost
Copy link

ghost commented Nov 6, 2014

I have defined a context menu with a submenu, which (the submenu) needs to be populated dynamically (through an ajax call).

Whatever I do, the submenu is converted to a plain entry as soon as I call "setEntry" on it.

Here is the relevant code: http://jsfiddle.net/yuwLc47b/

As you can see, the submenu is modified in the "beforeOpen" function - and this seems to remove the submenu completely.

The context of this is a multi-user interface, where I would like to offer the users valid actions only (instead of offering all actions and erroring out if the action became invalid in the meantime by other user's action), therefore the need for modification at the click-time.

I also tried to modify the "ul" which is the base for the context menu, but here I face other issues:

  • when trying to replace the whole menu in the "beforeOpen", the menu does not show up at all
  • when replacing only the dynamic part, the submenu title is removed (and replaced by the #identifier of the "
  • " element...)
  • when replacing the dynamic part and then explicitly setting the title (by calling "setEntry", "entry", "title" again), the title is shown as expected but the behaviour breaks: I then cannot click on the submenu item without explicitly clicking on the submenu first.

Any suggestions?

@mar10
Copy link
Owner

mar10 commented Nov 6, 2014

That's true, nested entries are not yet supported. Thanks for bringing this up

I guess if you initialize from an ajax call, you want to open another request, because you probably have to defer the opening until the request returns.
Something like this: a modification of the beforeOpen event:
we could allow to return a deferred/promise, and the context menu open would be delayed until the promise is resolved.

@ghost
Copy link
Author

ghost commented Nov 6, 2014

You are right, I completely missed the fact that the execution of
"beforeOpen" continues even after the ajax call is initialized... How could
I miss that?

@ghost
Copy link
Author

ghost commented Nov 7, 2014

I modified my ajax call to be synchronous now (yes, this does generates a warning in the Firefox console for me every time because sync calls on main thread are discouraged) - nevertheless no luck, cannot update the structure.

@mar10
Copy link
Owner

mar10 commented Nov 7, 2014

I already accepted this as a missing feature. And I added another Issue for the async dupport (#81)

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

No branches or pull requests

1 participant