Skip to content

eles.one(events, callback?)

eles.one — Collection > Events. Cytoscape.js signatures, parameters and return contract.

eles.one — Collection › Events

Preview · Collection › Events

Read in the complete API reference · All API members

// Like on(), but each element's handler runs at most once
eles.one(events: string, callback?: EventHandler<NodeData, EdgeData>): this

Like on(), but each element's handler runs at most once.

Parameters
NameDescription
events: string

one or more space-separated event names

callback: EventHandler<NodeData, EdgeData>?

the handler

Returns this

this collection, for chaining

Example

let count = 0;
cy.getElementById('a').one('example', () => count++);
cy.getElementById('a').emit('example');
cy.getElementById('a').emit('example');
console.log(count); // 1

Example graph and handle setup

Also spelled eles.once.