Closed lilfrootyloops closed 2 years ago
@lilfrootyloops
Firstly, you cannot push while defining an object. submenu.push
This call not be inside the object definition.
Secondly, if you read the API and documentation, you will see an appendMenuItems this might be best way to append new items dynamically.
Description: In my Next.js application, I am trying to create a submenu that is dynamically updated to include specific options depending on what kind of node has been selected. The values for the submenu items are already being passed into the overarching menu via an
evt
object. I have tried usingsubmenu.push()
; however, I am running into the following error:Before putting together functionality within the
push()
method to dynamically grab items fromevt
to create objects out of them, I tried running thepush()
method on pre-defined objects to test whether this concept would work in general; however, it did not for me. I'd really appreciate it if someone could point out what I may have been doing wrong and explain how I can dynamically add items in a submenu — if it's possible. I've included my code below:Code:
Additional Context I am using Cytoscape Context Menus v4.1.0.