Enable TipTip for dynamically created elements

Thomas's Avatar

Thomas

14 Oct, 2010 08:13 AM

Hello all,

first of all, I really like the TipTip plugin! Thanks for it!

But there is one problem.. When I create a new element via jQuery (doesnt matter if I insert the whole element as an HTML string via .html() or if I use document.createElement), TipTip will not work for that element.
I also tried to re-create TipTip with $(".tooltip").tipTip() or newElement.tipTip(), but this also does not work..

Could you please help me?

  1. 1 Posted by Goran on 19 Nov, 2010 09:11 AM

    Goran's Avatar

    You can use a function for this. I made it work in one of my projects like this. I created a function:

    function enableTipTip(selector){
                $(selector).tipTip({
                        delay: 100,
                        fadeIn:50,
                        fadeOut:50
                });
        }

    Then in your ajax callback function or similar just call this function. Like this:

    $.post("mywebsite/action", {
                        data: data
                }, function(data){
                        enableTipTip('.someClass');
                })
  2. 2 Posted by senthil on 23 Mar, 2011 11:21 AM

    senthil's Avatar

    it working fine.... Thank u...

  3. 3 Posted by soundsystem on 31 Mar, 2012 02:20 PM

    soundsystem's Avatar

    Being a total beginner at JS, could I perhaps get some directions on how to use this exactly? This is my code:

    jQuery(function($) {  
      $('div.wrapper').hover(
        function() {
          $(this).append("
    
    ");
          },
        function() {
          $(this).children('div#inner').hide();
        }
      );
    });
    

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