Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Using 2 qtips on 1 element with different triggering events
18th May, 09:47
Post: #1
Using 2 qtips on 1 element with different triggering events
I want to use qTip both for a hovering tooltip and a onclick-dialog on the same element. So if the user hovers over the element, some static information should be displayed, but if the element is clicked, an AJAX-loaded form should appear. I'd like to use qTip for both cases to get a more consistent styling and interface.

Is this possible? Or should I create the qtip instance on the fly when clicking the element (and thus remove the hover qtip and replace it with the other one)?
Find all posts by this user
Quote this message in a reply
18th May, 18:29
Post: #2
[Solved] Using 2 qtips on 1 element with different triggering events
This is indeed possible and very easy to accomplish. It's not documented yet, but you also need to be aware of how multiple qTip's are handled on a single element if you're going to use the API functionality for both.

First, create the qTips as usual using the qTip call like so:
JS Code
$('.selector').qtip({ options here });


You can do this as many times you want on a single element, and they will all activate normally as seperate entities, just like they would if you were referencing multiple elements.

When you create a tooltip on an element, the most recently created tooltips API is available through the use of the regular API retrieval like so:
JS Code
$('.selector').qtip('api')


However, if you have more than one tooltip present on an element, in order to access the API of each individual tooltip you'll have to use one of two methods:
1. Reference the tooltip directly instead of the target element and retrieve it from there
2. Utilise the new interfaces object introduced in RC3 onwards

In order to use the second method, you need to know a few things. First is to know how to access an elements interfaces object.

Each element, when creating a tooltip on it, automatically receives an interfaces array. This array contains references to all qTips (e.g. thieir API's) currently targeting that element. It can be retrieved like so:
JS Code
$('.selector').qtip('interfaces');


Second, the interfaces array has the 'current' property, which contains the array index of the most recent tooltip created on that element. Tooltips are stored in the array from most old to most recent. Therefore, when you call the .qtip('api') method, what you're actually doing is retrieving the last API object within the interfaces array. So this:
JS Code
$('.selector').qtip('api')

...is equivalent to...
JS Code
$('.selector').qtip('interfaces')[ $('.selector').qtip('interfaces').current ];


So for example, if I wanted to hide the first tooltip I created e.g. in your case the 'on hover' tooltip, I could do this:
JS Code
$('.selector').qtip('interfaces')[0].hide();


And if I wanted to hide the second (last created) tooltip e.g. in your case the 'click' tooltip, I could use either of these two methods:
JS Code
var interfaces = $('.selector').qtip('interfaces');
interfaces[ interfaces.current ].hide();

JS Code
$('.selector').qtip('api').hide();


And that's about it. Obviously all API functionality is available using these methods, but you get the general idea I hope.

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
4th January, 15:22
Post: #3
RE: Using 2 qtips on 1 element with different triggering events
I have 2 qtips created on a same element at a different time and condition. When working on them, is there a id to find out the right Qtip. As The order they get created is random, I am not sure $('#selectorid').qtip('interfaces')[0] is always the the one I want or the current one $('.selector').qtip('api')
is the always the one I want.

I want to find a qtip by id (2 qtips on a same element) to update its content.

how to solve the problem.?
Find all posts by this user
Quote this message in a reply
6th January, 03:10
Post: #4
RE: Using 2 qtips on 1 element with different triggering events
ramalaks, there isn't unfortunately... you might try out qTip2 and checkout the tutorial here: http://craigsworks.com/projects/qtip2/tu...ced/#multi

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
8th February, 22:22
Post: #5
RE: [Solved] Using 2 qtips on 1 element with different triggering events
I solved the problem by saving the data retrieving it..

jQuery('#'+id).data("qtip1", jQuery('#'+id).qtip("api")); (save)

api = jQuery('#'+id).data("qtip2");( retrieve..)

thanks
Ramalaks
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Solved] Dynamic Content From Page Element frogg3862 2 91 3rd May 17:12
Last Post: frogg3862
  [Solved] Multiple qtips on one page, content disappearing russau 3 123 3rd May 16:38
Last Post: Craig
  calling .html using the element id matthearn 0 309 24th February 15:08
Last Post: matthearn
  Qtips with jquery UI Issue sherwoodbear79 2 439 15th February 15:36
Last Post: sherwoodbear79
  [Solved] Attach QTIP to any element with attribute "tooltip" slhilbert 7 405 15th February 14:44
Last Post: slhilbert
  [Solved] How to append QTip to some other element instead of document body prateekbansal 2 501 11th January 07:01
Last Post: prateekbansal
  [Solved] QTip content from existing div element on page? dcash 4 2,527 8th December 18:29
Last Post: Craig
  [solved] Trouble with qtips adding a scrollbar momentarily to window patricia 0 352 2nd December 19:40
Last Post: patricia
  Changing HTML Content on Click & Remove/Reinit qTips ifthatdoesntdoit 5 1,228 17th November 09:46
Last Post: ifthatdoesntdoit
  nested lists and qtip for the last mouseenter element ??? thbenda 0 340 4th October 09:24
Last Post: thbenda



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