Search code examples
javascriptjqueryfacebox

What's the facebox 'hooks'


/*
* 
*  Facebox also has a bunch of other hooks:
*
*    loading.facebox
*    beforeReveal.facebox
*    reveal.facebox (aliased as 'afterReveal.facebox')
*    init.facebox
*    afterClose.facebox
*
*/

I'm using Facebox. In source codes I found some hooks, but I can only find one line that use "beforeReveal":$(document).trigger('beforeReveal.facebox'). I can't find where it is defined. So I wonder how it works. Hope to get some help. Thx a lot!


Solution

  • Those are simply custom events (while e.g. click is a pre-defined event) that you can subscribe to:

    $(document).on('beforeReveal.facebox', function() {
        // This code here is now executed every time before the facebox is revealed,
        // because Facebox triggers this event.
    });
    

    Read more in the docs: http://api.jquery.com/trigger/