tipTip and jQuery .live()

stephen's Avatar

stephen

06 Jul, 2011 11:50 AM

I need tipTip pop-ups on items that are created dynamically. I know that the .live() method should help with this but I cant figure how to use it with tipTip

  1. 1 Posted by Saurabh on 28 Jul, 2011 11:56 AM

    Saurabh's Avatar

    There is a trick to work around to make it work for such dynamic elements. You can do something like this...

    $("#element").live("hover", function() { $("element").tipTip() });

    On first hover it won't show the tooltip, but will work as expected for next hover. If you are okay with that you can opt this way.

    But the script need to be updated so that tipTip will work for dynamic contents.

  2. 2 Posted by Andrew Hao on 04 Oct, 2011 05:00 PM

    Andrew Hao's Avatar

    To expand on that, you can get it to hover on first by triggering a synthetic event.

    $("#element").live("mouseover", function() { $("#element").tipTip() $("#element").trigger('mouseenter'); });

    Note how this only doesn't infinite loop because mouseover and mouseenter are different events.

  3. 3 Posted by Adam on 21 Oct, 2011 08:47 PM

    Adam's Avatar

    Andrew's solution works well except in Internet Explorer 8 (I didn't test 6 or 7) the default tooltip appears the first time. I came up with a workaround that uses the "Live Query" jQuery plugin:

    $('a[title]').livequery(function() { $(this).attr('title', function(i, title) {

    $(this).data('title', title).removeAttr('title');
    

    }); });

    $('a:data(title)').live('mouseover', function() { $(this).attr('title', $(this).data('title'));

    $(this).tipTip({

    delay: 200,
    maxWidth: '400px'
    

    });

    $(this).trigger('mouseenter'); });

  4. 4 Posted by Hari on 11 Sep, 2012 09:48 AM

    Hari's Avatar

    Hi Andrew Hao,

    Your solution works for me in IE8 and firefox, but in IE7, mouseover and mouseenter , it is getting in infinite loop. How to fix this.

    thanks in advance

    Regards
    Hari

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac