Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Global qtip elements with different content
14th April, 06:57
Post: #1
Global qtip elements with different content
Hi All,

In brief, what I want to do is have multiple qtip tooltips on one page but I don't want to have to set the common elements between them all each time I want to display a tooltip.

I want to have something similar to the following

JS Code
$('a.myqtip').qtip({
 
      hide: 'mousedown',
      show: {
                  when: false, // Don't specify a show event
                  ready: false // Show the tooltip when ready
               },
      style: 'qtipinfo',
      position: {
                  corner: {
                     tooltip: 'leftMiddle', // Use the corner...
                     target: 'rightMiddle' // ...and opposite corner
                  }
               }
   })


That would set all links with a class="myqtip" to have the common elements.

Then what I would like is just the ability to set the content with the following
JS Code
$('#testqtip').qtip({
      content: 'This is my tooltip1';   
   })
 
$('#testqtip2').qtip({
      content: 'This is my tooltip2';    
   })


That way I would not have to set the above common elements in every qtip call which would begin to become lengthy get hard to maintain.

Is there a way to set all of the above common elements across all qtips on a page?

The code above is just rough and I don't expect it to work but you get the general idea of what I am trying to achieve

Thanks
Find all posts by this user
Quote this message in a reply
14th April, 13:43
Post: #2
Global qtip elements with different content
Hi camslaz,

This is quite easily achievable like you said if you use an array of content and jQuery's each method:

JS Code
var myContents = [
  'my first tooltip content', 'my second', 'my third', 'you get the idea hopefully!'
];
 
$('a.myqtip').each(function(i) // Notice the 'i' variable which keeps the current element count
{
   $(this).qtip({
      content: myContents[i], // Get the current 'i' variables content
      hide: 'mousedown',
      show: {
         when: false, // Don't specify a show event
         ready: false // Show the tooltip when ready
      },
      style: 'qtipinfo',
      position: {
         corner: {
            tooltip: 'leftMiddle', // Use the corner...
            target: 'rightMiddle' // ...and opposite corner
         }
      }
   });
});

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
15th April, 03:10
Post: #3
Global qtip elements with different content
Thanks Craig... works perfectly!
Find all posts by this user
Quote this message in a reply
16th August, 23:01
Post: #4
Global qtip elements with different content
This is one of the most useful trick imo, maybe worse including in the tutorial?
Find all posts by this user
Quote this message in a reply
17th August, 12:50
Post: #5
Global qtip elements with different content
I'll be adding this as a tutorial to the new documentation jd Smile

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
6th November, 22:45
Post: #6
Global qtip elements with different content
Great way to apply common code-shrinking technique. Definitely a tutorial must-have. Thanks for the awesome plugin Craig!
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Solved] qtip showing content from db doesn't change when content in db changes. vtoepel 2 136 23rd April 16:02
Last Post: vtoepel
  [Solved] QTip content from existing div element on page? dcash 4 2,496 8th December 18:29
Last Post: Craig
  [Solved] Using same tooltip object for multiple elements rextheranter 3 787 1st August 15:26
Last Post: Craig
  Trying to load Dynamic Content using qTip v1 sman1 1 980 6th June 11:38
Last Post: Craig
  qtip for dynamic images & content cooldeeps 2 1,185 6th May 16:30
Last Post: cooldeeps
  [Solved] Using dynamically loaded content as well as DOM content; 'this' troubles distobj 1 1,101 2nd April 14:11
Last Post: Craig
  Print qTip content (pdf in iframe) Thilo 2 2,468 18th March 12:49
Last Post: deveshelles
  qTip and Forms, how to access form input/elements/form data? lancelot_one 2 1,555 15th February 21:43
Last Post: lancelot_one
  qtip with dynamic content using vb.net mrnorway 1 1,190 13th February 16:33
Last Post: Craig
  [Solved] tip position when using global styles xenolith5 2 1,026 3rd February 09:17
Last Post: xenolith5



User(s) browsing this thread: 1 Guest(s)