vNext
vNext

Reputation: 1122

live binding for bassistance tooltip (http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/)

How can I use live binding for bassistance tooltip (http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/)

I'm using this code:

$(document).ready(function(){
   $('.tooltip[title]').tooltip({
       track: true,
       delay: 0,
       showURL: false,
       showBody: " - "
});});

So, how can I bind it using live binding?

Upvotes: 0

Views: 324

Answers (1)

lucuma
lucuma

Reputation: 18339

I can think of 2 ways to achieve this:

  1. Since you are updating your document either with ajax calls or via some other way, you can make that same call you have inside the area where you are adding the newly created elements. Here is a demo using a different qtip but the strategy is identical: http://jsfiddle.net/lucuma/2EnFV/

  2. If you can't add the tooltip via ajax success then the following code will work. It adds a new class to elements that have the tooltip plugin. If the class isn't there on mouseover it will add the class and open the plugin.

http://jsfiddle.net/lucuma/WtqYA/

$(document).ready(function() {
    $(document).on('mouseover', '.tooltip[title]', function() {
        if (!$(this).hasClass('applied')) {
            $(this).tooltip({
                track: true,
                delay: 0,
                showURL: false,
                showBody: " - "
            });

            $(this).mouseover();
        }
    });
});

Lastly you may consider using a plugin that is actively developed such as qtip or jquery tools.

http://craigsworks.com/projects/qtip/

http://jquerytools.org/

Upvotes: 2

Related Questions