• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1312
  • Last Modified:

Javascript: JQuery tooltip plugin - Multiple tooltips using one set of parameters

I'm using the Tooltip plugin for JQuery from www.bassistance.de, although i think the question just needs some javascript to be rearranged to fix my problem

I have multiple (about 15) image tooltips that are attached to a series of HTML labels.

All the tooltips use the same plugin parameters:
      track: true,
      delay: 0,
      showURL: false,
      showBody: " - ",
      fixPNG: true,
      left: 30,
      top: -100,

Its only the "extraClass:" used to style and select which image is displayed that differs.

How can i reduce code by stating the tooltip parameters just once for all tooltips, and then change the extraClass per tooltip?
So the final code looks something like this:

$(function() {
$('.tooltip01, .tooltip02, .tooltip03').tooltip({
      track: true,
      delay: 0,
      showURL: false,
      showBody: " - ",
      fixPNG: true,
      left: 30,
      top: -100
});
$('.tooltip01').tooltip({       extraClass: "tooltip01_css" });
$('.tooltip02').tooltip({       extraClass: "tooltip02_css" });
$('.tooltip03').tooltip({       extraClass: "tooltip03_css" });
});

Thanks for any help

0
ticallian
Asked:
ticallian
1 Solution
 
TimYatesCommented:
Can't you do this:
var opts = {
      track: true,
      delay: 0,
      showURL: false,
      showBody: " - ",
      fixPNG: true,
      left: 30,
      top: -100
}
$('.tooltip01').tooltip( $.extend( opts, { extraClass:'tooltip01_css' } ) ) ;
$('.tooltip02').tooltip( $.extend( opts, { extraClass:'tooltip02_css' } ) ) ;
$('.tooltip03').tooltip( $.extend( opts, { extraClass:'tooltip03_css' } ) ) ;

Open in new window

0
 
ticallianAuthor Commented:
Works perfectly, many thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now