jquery tooltipster work only on second hover

1.5k Views Asked by At

i found problem like mine here, but no one topic help me, so i decide to write my own.

Problem : i need to 'mouseover' twice to see tip. And i know this is because i call tooltip on second mouseover, but i have no idea, how to solve my problem. I will be very thankful for any suggestion or help!

jquery :

$(document).ready(function() {

    $('.playerTip').mouseover(function(){
        var playerID = $(this).attr('rel');
        $(this).tooltipster({
            contentAsHTML: true,
            content: 'Loading...',
            functionBefore: function(origin, continueTooltip){
                continueTooltip();
                if(origin.data('ajax') !=='cached'){
                    $.ajax({
                        type: 'POST',
                        url: 'http://localhost/Statystyki/index.php/home/tooltip',
                        data: "player="+ playerID,
                        success: function(data) {
                            origin.tooltipster('content', data).data('ajax', 'cached');

                        }
                    });
                }
            }

        });
    });
});

and html:

<a href="#" class="playerTip" rel="426">XYZ</a>
<a href="#" class="playerTip" rel="174">DFV</a>
<a href="#" class="playerTip" rel="184">DRT</a>

etc

@solved well i solve my problem ;)

if anybody need solution:

$(document).ready(function() {

        var playerID

    $('.playerTip').mouseover(function(){

        playerID = $(this).attr('rel');

        });

    $('.playerTip').tooltipster({
        contentAsHTML: true,
        content: 'Ładuje...',
        functionBefore: function(origin, continueTooltip){
            continueTooltip();
            if(origin.data('ajax') !=='cached'){
                $.ajax({
                    type: 'POST',
                    url: 'http://localhost/Statystyki/index.php/home/tooltip',
                    data: "player="+ playerID,
                    success: function(data) {
                        origin.tooltipster('content', data).data('ajax', 'cached');

                    }
                });
            }
        }
        });
});
0

There are 0 best solutions below