Aatish Molasi
Aatish Molasi

Reputation: 2186

load ajax content before showing tooltip

THIS IS THE CODE TO CREATE AN ARRAY of TOOLTIP OBJECTS

    $(document).ready(function(){
         var show = false;
         var tips = new Array();
             $(".replie").each(function(){
                $(this).tooltip({ effect: 'fade', events:  {widget:'click,'},position:"bottom right",onBeforeShow:function() {
                    this.getTrigger().fadeTo("slow", 0.8);
                    }})
                tips.push($(this).tooltip(0));
                });

AND THIS IS THE CODE TO CONTROL THE TOOLTIPS BEHAVIOR AND LOAD AJAX CONTENT

    $(".replie").click(function(evt){
        if(!evt){
                    evt=window.event;
                }
            var row =evt.target.parentNode.id[2];
            var aid=evt.target.id;
            var uid= <?php echo $uid ?>;
            var tip;
            $("#tip"+row).load("reply.php?uid="+uid+"&aid="+aid,function(){
                $(this).hide()
            });

            if(tips[row].isShown)
            {
                tips[row].hide();
            }
            else
            {
                tips[row].show();
            }

        });

HOW DO I LOAD THE CONTENT AND THEN SHOW THE TOOLTIP .. ?

Upvotes: 1

Views: 799

Answers (1)

Sanghyun Lee
Sanghyun Lee

Reputation: 23002

Use jQuery.ajax() function instead of jQuery.load() function. You can set a callback function on complete or success event. Inside that handler, trigger the tooltip function.

This is the documentation of jQuery.ajax(): http://api.jquery.com/jQuery.ajax/

Upvotes: 2

Related Questions