Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can't destroy tooltip and ending up with 2 tooltips on one div
2nd March, 06:19
Post: #1
can't destroy tooltip and ending up with 2 tooltips on one div
Hi,

I am loading a page 2 (jquery ui dialog) and on the second loading I am trying to change the tooltip. However what I end up with is 2 tooltips instead of one with the new content.

I've tried to do the $(myselector).qtip('destroy') but it crashes on line 1524 of * Version : 1.0.0-rc3 downloaded just now from http://bazaar.launchpad.net/~craig.craig.../1.0/files

JS Code
$.fn.qtip = function (options, blanket) {
		var i, id, interfaces, opts, obj, command, config, api;
 
		// Return API / Interfaces if requested
		if(typeof options === 'string') {
			// Return requested object
			if(options === 'api') {
				return $(this).data('qtip').interfaces[$(this).data('qtip').current];
			}
			else if(options === 'interfaces') {
				return $(this).data('qtip').interfaces;
			}
		}



anyone got any ideas. This is my routine I've built and put in a common js file

JS Code
this.addToolTip = function(elementId, message){
 
 
 
        //start by clearing out any existing messages
        $("#"+elementId).qtip('destroy')
 
 
        var _corner;
        var _target;
        var _tip;
        if($("#"+elementId).is(':radio') || $("#"+elementId).is(':checkbox'))
        {
        _corner='bottomMiddle'
        _target='topMiddle'
        _tip = 'bottomMiddle'
        }
        else
        {
        _corner='leftMiddle'
        _target = 'rightMiddle'
        _tip = 'leftMiddle'
        }
 
    $("#"+elementId).qtip({
    content: message,
        position:{corner:{tooltip:_corner,target:_target}},
        style: {
            tip: {corner: _tip, size: {x:10, y:10}},
            name: 'green',
            border:{width:2, radius:5}
        }
    });
 
    };


thanks
Find all posts by this user
Quote this message in a reply
2nd March, 19:13
Post: #2
RE: can't destroy tooltip and ending up with 2 tooltips on one div
Are you updating your content by any chance kurtmarr? If you're removing elements with qTips attached make sure to call the .qtip('destroy') first.

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
2nd March, 22:16 (This post was last modified: 2nd March 22:17 by kurtmarr.)
Post: #3
RE: can't destroy tooltip and ending up with 2 tooltips on one div
(2nd March 19:13)Craig Wrote:  Are you updating your content by any chance kurtmarr? If you're removing elements with qTips attached make sure to call the .qtip('destroy') first.

Hi Craig. Thanks for your answer. As you can see by my code I am trying to call 'destroy' first but it crashes on line
JS Code
return $(this).data('qtip').interfaces



Any ideas?

thanks
Find all posts by this user
Quote this message in a reply
2nd March, 22:29
Post: #4
RE: can't destroy tooltip and ending up with 2 tooltips on one div
(2nd March 22:16)kurtmarr Wrote:  
(2nd March 19:13)Craig Wrote:  Are you updating your content by any chance kurtmarr? If you're removing elements with qTips attached make sure to call the .qtip('destroy') first.

Hi Craig. Thanks for your answer. As you can see by my code I am trying to call 'destroy' first but it crashes on line
JS Code
return $(this).data('qtip').interfaces



Any ideas?

thanks

I'm not sure if this is the right way to go about it, but it works for me:

From what I can tell, the problem you're having is that your code doesn't check if there is a qtip attached or not (on first run, I assume it doesn't).

Try:

JS Code
if($("#"+elementId).data("qtip")) $("#"+elementId).qtip("destroy");
Find all posts by this user
Quote this message in a reply
3rd March, 01:01
Post: #5
RE: can't destroy tooltip and ending up with 2 tooltips on one div
sweet. Now it works.

Thanks

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


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Solved] Pausing Vimeo on tooltips called with AJAX? daver_cl 4 366 14th March 20:39
Last Post: Craig
  [Solved] qTip Ajax data for text in a div akhil_csit 1 306 14th March 19:27
Last Post: Craig
  can't hide qtip in a “position: absolute;” div shdog 1 267 14th March 17:35
Last Post: Craig
  [Solved] ColdFusion & Tooltips shimmoril 2 322 13th February 14:48
Last Post: shimmoril
  Tooltips not loading jQuery or other js files from parent document crodesign 2 465 13th January 22:19
Last Post: crodesign
  show qtip in a specified div or position myapweb 1 572 27th December 17:53
Last Post: Craig
  [Solved] Autohide tooltips after set time phuson 25 4,063 9th December 11:40
Last Post: stevenday
  [Solved] QTip content from existing div element on page? dcash 4 2,495 8th December 18:29
Last Post: Craig
  [Solved] Problem with Fixed Position div and scrolling homerlex 7 1,433 26th October 19:35
Last Post: Craig
  [Solved] Is there an easier way to show/hide tooltips dynamically? gloosemo 1 665 17th October 15:58
Last Post: Craig



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