question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] new added node not listen on events via `eles.on()`

See original GitHub issue

Issue type

Bug report

Environment info

  • Cytoscape.js version : v3.5.1
  • Browser/Node.js & version :

Current (buggy) behaviour

After a new node is added to the graph, events on e.g. cy.nodes().on('click') are not executed, but are available via cy.on('click', 'node').

Desired behaviour

Listen on events after adding a new node to the graph via cy.nodes().on('click')

Minimum steps to reproduce

  1. Click on a node:
// console output
cy.nodes().on(click)
cy.on(click, node)
  1. Add new node via the button on top
  2. Click on new node
// console output
cy.on(cxttap, node)

https://jsbin.com/ligesehera/edit?html,js,console,output

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
sgratzlcommented, Jul 13, 2020

I think it is similar to JQuery on and the deprecated live. https://api.jquery.com/live/.

You are looking for that the .nodes() collection is always uptodate with the current nodes. However, as far I know it it is just a snapshot of the nodes at the moment you call .nodes().

0reactions
maxkfranzcommented, Jul 16, 2020

I’m not familiar with any tools that handle collections in an automatically updating way. How would that work with the set theory operations, or what if you wanted to diff an old set of nodes with a new set of nodes?

Where do you think would be the best place in the documentation to address your issue? Maybe eles.on()? Would you be open to writing a few sentences that would help to clarify things for people like you, who run into this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Event listeners not working? 3 key areas to troubleshoot
Are your event listeners not working as you'd expect? Here are 3 key areas to troubleshoot to help you get everything triggering as...
Read more >
Node js event listener not working as expected - Stack Overflow
So im basically trying to emit and listen to a specific event on different typescript classes. The first event that is emitted is...
Read more >
EventTarget.addEventListener() - Web APIs | MDN
It works on any event target, not just HTML or SVG elements. The method addEventListener() works by adding a function, or an object...
Read more >
[bug?] Why can't capture the error in events #3882 - GitHub
If server.on('error' happened and error's code is EADDRINUSE , then it says that the port 80 is already used. In this scenario, reject(err) ......
Read more >
Events | Node.js v19.3.0 Documentation
When a listener is registered using the eventEmitter.on() method, ... As a best practice, listeners should always be added for the 'error' events....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found