View Full Version : Javascript to capture when photo changes
fitter man
Nov-21-2008, 07:00 AM
I'm looking to hook into a Javascript event that will tell me when the user has switched to a different "main" image (that is the large image on the right-hand side of the SmugMug style). I'm okay-ish with Javascript but I'm really not sure what event might do it. I tried using onload for the <img id="mainImage"... > tag, but that didn't cut it; I assume because some Ajax function is replacing the part of the DOM that contains the image.
My goal is to do some post-processing to the caption each time it changes, and that's really what I want to detect has changed. So, if you have any suggestions, they would be greatly appreciated.
jfriend
Nov-21-2008, 03:51 PM
I'm looking to hook into a Javascript event that will tell me when the user has switched to a different "main" image (that is the large image on the right-hand side of the SmugMug style). I'm okay-ish with Javascript but I'm really not sure what event might do it. I tried using onload for the <img id="mainImage"... > tag, but that didn't cut it; I assume because some Ajax function is replacing the part of the DOM that contains the image.
My goal is to do some post-processing to the caption each time it changes, and that's really what I want to detect has changed. So, if you have any suggestions, they would be greatly appreciated.
Use this
onPhotoShow.subscribe(yourFunction);
and yourFunction will get called everytime a new main image gets displayed, including the first time.
fitter man
Nov-28-2008, 07:48 AM
Thanks. I am curious if there's either documentation anywhere where I can find other goodies like this one or if there's a particular file I might want to peruse to learn more on my own.
jfriend
Nov-28-2008, 11:54 AM
Thanks. I am curious if there's either documentation anywhere where I can find other goodies like this one or if there's a particular file I might want to peruse to learn more on my own.
I am not aware of any documentation for this kind of stuff. I've asked and look for it before too. I only know about it from discussion here on dgrin.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.