Edit this page

one

Attaches a handler to an event. The handler is executed only once.

Parameters

eventName String

The name of the event.

handler Function

A function to execute each time the event is triggered. That function should have a single parameter which will contain any event specific data.

Important: The context (this) of the handler function is set to the observable object itself.

Example - subscribing to an event

<script>
var obj = new kendo.Observable();
var numberOfCalls = 0;
obj.one("myevent", function() {
    numberOfCalls ++; // increment the counter every time the handler is executed
});
obj.trigger("myevent"); // fire the event
obj.trigger("myevent"); // fire the event
console.log(numberOfCalls); // outputs "1"
</script>
Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy