PDA

View Full Version : How to change images that pop up in tooltips?



BobH
03-02-2011, 08:11 PM
1) Script Title: Image w/ description tooltip v2.0

2) Script URL (on DD): Script: DD Tab Menu
http://www.dynamicdrive.com/dynamicindex4/ddimgtooltip.js

3) Describe problem:

:confused:
The sample initialization assumes that you will define values in an array called tooltips, within the tiparray function, only once, when the script is first called.

In my application, I have a list of images. When the user selects an item in the list, six versions of the image appear in a table of thumbnail images for a preview of cropping and text placement done by the application. I want to use this script to pop up a window of these six images.

No matter what I have tried, I am unable to change the items that pop up when the user selects a second or third image from the main list. The thumbnails change, but hovering always pops up the full-size image that first was loaded into tool.

The intended target looks like this (with the src filled in my script):

<a href="#" rel="imgtip[1]"><img id="preview_1" src=""/></a>

I noticed that the init function at the bottom of the script creates code to be called by jquery when the document is loaded. I tried duplicating this, without the call to jquery(document).ready, in a function called

refreshToolTips: function(targetselector) {
var tiparray=ddimgtooltip.tiparray
var $targets=$(targetselector)
if ($targets.length==0)
return
...
}

In my code that runs when the user selects an image from the list, I tried this (hard-coding the tiparray value just as a test):

ddimgtooltip.tiparray[1] = 'images/renditions/bag_1.jpg';
ddimgtooltip.refreshToolTips("*[rel^=imgtip]");

This did not help. The $targets array was empty, so the function just returned. I might have other problems, too, but I believe I have correctly set the value of ddimgtooltip.tiparray[<my_index>].

I understand regular expressions very well, but I don't know jQuery and don't understand that target selector syntax. What am I missing?

ddadmin
03-04-2011, 08:35 AM
I have a general sense of what you might be trying to do, but it'll be much clearer if you can post a link to the page in question containing what you have so far.