Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

258
Views
¿Cómo puedo agregar dinámicamente elementos en un submenú utilizando la biblioteca de menús contextuales de Cytoscape?

En mi aplicación Next.js, estoy usando la biblioteca de menús contextuales de Cytoscape para crear un submenú que se actualiza dinámicamente para incluir opciones específicas según el tipo de nodo que se haya seleccionado. Los valores de los elementos del submenú ya se pasan al menú general a través de un objeto evt . He intentado usar submenu.push() ; sin embargo, me encuentro con el siguiente error:

Error de sintaxis: Token inesperado, esperado ","

Antes de reunir la funcionalidad dentro del método push() para tomar elementos de forma dinámica de evt para crear objetos a partir de ellos, intenté ejecutar el método push() en objetos predefinidos para probar si este concepto funcionaría en general; sin embargo, no lo hizo para mí. Realmente agradecería si alguien pudiera señalar lo que puedo haber estado haciendo mal y explicar cómo puedo agregar dinámicamente elementos en un submenú, si es posible. He incluido mi código a continuación:

 const options = { evtType: 'cxttap', menuItems: [ { id: 'one', content: 'This is the first option in the menu', selector: 'node', onClickFunction(evt) { genericFunctionName(evt, 'one') }, }, { id: 'two', content: 'This is the second option in the menu', selector: 'node', onClickFunction(evt) { genericFunctionName(evt, 'two') }, }, { id: 'three', content: 'This is the third option in the menu', selector: 'node', onClickFunction(evt) { console.log(evt.target.data('properties')); }, submenu: [ { id: 'submenuOne', content: 'This is the first option in the submenu', tooltipText: 'blue', onClickFunction: function () { console.log("The first option in the submenu was clicked on") }, }, { id: 'submenuTwo', content: 'This is the second option in the submenu', tooltipText: 'blue', onClickFunction: function () { console.log("The second option in the submenu was clicked on") }, }, ], submenu.push( { id: 'submenuThree', content: 'This should be the third option in the submenu', tooltipText: 'blue', onClickFunction: function () { console.log("The third option in the submenu was clicked on") }, }, ), }, ], };

FWIW, estoy usando Cytoscape Context Menus v4.1.0.

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!