Skip to content
maxkfranz edited this page Mar 8, 2012 · 4 revisions

eles.one()

Add a callback function to be called one time when an event first occurs for each element.

eles.one( eventType, function(eventObject) )

Runs the specified callback function the next time the specified event occurs for each element

eventType A list of event types to bind to the elements.
function(eventObject) The callback function to be executed only the first time per element when the event occurs after binding.

Details

This function triggers a specified callback function the first time each specified event occurs on each element.

If you want to have a callback function execute once per a collection, use col.once().

Examples

Print a message the first time n1 is clicked after binding:

cy.nodes("#n1").one("click", function(){
  console.log("1st click of n1");
});

Clone this wiki locally