Solved

JS plugin Qtip2 popup customisation

Posted on 2014-12-12
2
236 Views
Last Modified: 2014-12-15
on my page i have an image, with an image map e.g.
<map id="points" name="points">   
        <area shape="circle" alt="point 1" coords="79,165,5" href="chapt1.pdf">
        <area shape="circle" alt="point 2" coords="60,165,5" href="#chapt2">
        ...

Open in new window

using the qtip2 plugin, i can make the points hotspots, however, i would like to customize the popup's title and content area as below:

title text: area alt text e.g. point 1
content: clickable link to href value of area -  (<a href="chapt1.pdf">Point 1</a>) or at least, just clickable link to href value



full qtip config:
$(document).ready(function()
{
	

$('area[alt]').qtip({
   /* content: {
         attr: 'alt'
    },*/
	content: {
		attr: "href",// should be clickable link and display alt text (attr: 'alt')
		title: {text:"Download", //should be area alt text
      button: 'Close'}
         },
  position: {
             target: 'mouse', 
             adjust: {
                 mouse: false
             } 
         },
	 style: {
            classes: 'qtip-light'
        },show: { solo: true }
});

}); 

Open in new window

0
Comment
Question by:weaverk
  • 2
2 Comments
 
LVL 1

Accepted Solution

by:
weaverk earned 0 total points
ID: 40500545
$(document).ready(function () {
    $('area').each(function () { //loop through each hotspot, get the necessary values, and set them into required spots in that qtip
        urlLink = $(this).attr('href'); 
        urlName = $(this).attr('alt'); 
        $(this).qtip({

            content: {
                text: '<a href="' + urlLink + '">sometext</a>', //sometext could equally be the urlName
                title: {
                    text: urlName,
                    button: 'Close'
                }
            },
            position: {
                target: 'mouse',
                adjust: {
                    mouse: false
                }
            },
            style: {
                classes: 'qtip-light'
            },
            show: {solo: true}
        });
    });
});

Open in new window

0
 
LVL 1

Author Closing Comment

by:weaverk
ID: 40500547
this is my solution, comments in the code in case somebody else can benefit from this too...
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now