开发者

load ajax content before showing tooltip

  • I wanted to create a drop down at a certain position based on a users click and
  • I wanted this to come in the form of a drop down also
  • the content in the drop down would be dynamically genereated through ajax..
  • im using jquery-tools tooltip to do this but开发者_JAVA技巧 am facing some problem...
  • the ajax content is loading only after the second click ..

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 .. ?


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜