### About events in programming languages

Many programming language supports events or notifications. The basic concept is that you can subscribe to these events and the application will send you a notification or run some code when they accour, so you will have a chance to do something you may want to be done in certain points of your program. For example change the site's background when the slider switching slides.

### Javascript uses callback functions

In Javascript these events commonly used with callback functions. Instead of sending and receiving notifications, you just pass an anonymous function (also known as blocks in other languages) with your own code to a function or method call as a parameter and the application will execute it when the time has come. LayerSlider uses this kind of event handling.

### Events in LayerSlider

So we now by now the technique about event handling, lets see which kind of event LayerSlider has:

- cbInit: This event will fire when LayerSlider finished building up the DOM and successfully loaded. If you want to do something with the LayerSlider elements right on the start, you won't be able until LayerSlider has loaded, you have to use this event.
- cbStart: Calling when the slideshow has started.
- cbStop: Calling when the slideshow is stopped by the user.
- cbPause: Fireing when the slideshow is temporary on hold (for example by the "Pause on hover" feature).
- cbAnimStart: Calling when the slider commencing slide change (animation start).
- cbAnimStop: Fireing when the slider finished a slide change (animation end).
- cbPrev: Calling when the slider will change the previous slide by the user via previous button, keyboard navigation, or touch control.
- cbNext: Calling when the slider will change the next slide by the user via next button, keyboard navigation, or touch control.

### A simple example of a callback function

This simple example will alert the user when LayerSlider changed a slide. To do that we have to pass this function to the cbAnimStop event.

    function() {
    	alert('The slider switched to a new layer!');
    }

### What's next?

If you want to achieve something with the event callbacks, you probably instrested in our API. Please continue reading with the next section of this document.