Active
Project:
Lightbox2
Version:
6.x-1.x-dev
Component:
Documentation
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
27 Oct 2010 at 04:14 UTC
Updated:
21 Sep 2011 at 19:27 UTC
Is it possible to subscribe to event notifications for Lightbox2, so that we can run custom JS when the lightbox is displayed / closed / etc?
How are people handling this currently>
Comments
Comment #1
xurizaemonFound a solution to my initial question via StackOverflow.
I wanted to fire Drupal.zipcart.init() after the Lightbox was displayed.
Extend the Lightbox.updateNav function so it fires a custom event when called. This code can be added to site custom JS, and doesn't require patching Lightbox2 module.
Would be great to add some jQuery trigger() calls to Lightbox2 so this is simpler for people to do. For now, the above code works for me.
Comment #2
lobo235 commentedI would agree that adding jQuery trigger() calls to Lightbox2 would be highly beneficial. If my case, I need to use jQuery to modify the contents of the lightbox once it has been loaded via ajax.
Comment #3
onelittleant commentedI would recommend that the following Lightbox functions trigger events:
- start
- end
- pause
- togglePlayPause
- changeData
Thanks to grobot above. We used this approach to attach custom Google Analytics events to lightbox actions by hijacking the Lightbox.start function:
Comment #4
yukare commentedPlease, can you work on a real patch for this? If someone provides a patch to do this on lightbox in a general way(meaning that it works for all cases and not for a specific site/module) because there are many issues how to do things like this, and if we have a simple way to all cases, will be good.
I plan to make a new 6.12 release at the end of month.