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

180
Views
How to create poppers on new created Cytoscape.js graph elements?

I've been trying using popper extension of cytoscape.js, starting with the code I found on the web in order to do it, at https://codepen.io/rbogard/pen/mdyRPew

It woks quite well when initializing a graph and calling the popper creation when the rendered graph is ready for the user.

However I would like a popper to be created each time I'm adding a new node to the graph.

What I did is to call exactly the same function than the one call on cy.ready, which works perfectly well, on the event consisting to add a graph element.

The function makePopper is effectively called, however no popper appears when putting the mouse over the new added element.

cy.ready(function() {
  cy.elements().forEach(function(ele) {
    makePopper(ele);
  });
});

cy.on('add', function(ev) { 
  log("call poper")
  makePopper(ev.target);
})

I've been searching any exemple related to what I want to do, without success.

So I would like to know if someone already tried this, and has a solution for the dynamic update of poppers each time a new element is added to the graph.

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You didn't get what I said. You call

cy.elements().bind('mouseover', (event) => event.target.tippy.show());

just once at the beginning. You add MORE elements. So the new elements do NOT have such an event listener. So actually as you add new elements, you should attach new event listeners like

cy.on('add', (event) => {
  event.target.bind('mouseover', (event2) => {
    event2.target.tippy.show();
  })
});

In this case, you also need to remove your event listeners when an element is removed

cy.on('remove', (event) => {
  event.target.unbind('mouseover');
});

The best way is NOT to add events listener to the elements. Instead, you can add an event listener to the core like below.

cy.bind('mouseover', 'node', (event) => {
  event.target.tippy.show();
})

The above event listener will be fired whenever a node has hovered. Also, note that you should also call cy. unbind to unbind your event listener. This is for preventing memory leaks and strange bugs that might occur after cytoscape is destructed.

about 4 years ago · Juan Pablo Isaza Report
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!