2015-10-01 43 views
3

我有我的網站上這樣的代碼:JQuery的工具提示沒有AJAX負荷工作後

$(document).ready(function() { 

    $('.tooltip-game').jBox('Tooltip', { 
    closeOnMouseleave: true, 
    ajax: { 
     url: 'tooltips/tooltip-game-html.jsp', 
     reload: true, 
     getData: 'data-ajax', 
     setContent: true, 
     spinner: true 
    } 
    }); 

    $('#tabs-1').tabs({ 
    beforeLoad: function(event, ui) { 
     ui.panel.html('<div style="text-align: center; vertical-align: middle;"><img src="images/loading.gif" />'); 
     ui.jqXHR.fail(function() { 
     ui.panel.html("Couldn't load this tab. We'll try to fix this as soon as possible."); 
     }); 
    } 
    }); 
}); 

使用jQuery標籤和jQuery的工具提示,但加載與阿賈克斯外部文件後,提示不工作。我知道我必須使用。對()函數,但我不知道該怎麼:(

非常感謝你爲你的祕訣。

回答

1

您需要異步調用結束後,初始化工具提示。

function tooltips() {    
    $('.tooltip-game').jBox('Tooltip', { 
    closeOnMouseleave: true, 
    ajax: { 
     url: 'tooltips/tooltip-game-html.jsp', 
     reload: true, 
     getData: 'data-ajax', 
     setContent: true, 
     spinner: true, 
    //Take a look to this line 
     success: function() { 
      tooltips(); 
     } 
    } 
    }); 
}  


    $('#tabs-1').tabs({ 
    beforeLoad: function(event, ui) { 
     ui.panel.html('<div style="text-align: center; vertical-align: middle;"><img src="images/loading.gif" />'); 
     ui.jqXHR.fail(function() { 
     ui.panel.html("Couldn't load this tab. We'll try to fix this as soon as possible."); 
     }); 
    } 
    }); 
}); 
+0

非常感謝您的回答,但它不適合我。我不知道如何使負載:功能:(我搜查,但我有點失落。 – Harrison

+0

對不起,我錯過了load函數的參數,文檔中說''load'函數是在加載遠程標籤後觸發的:http://api.jqueryui.com/tabs/#event-load所以這個應該可以工作 –

+0

請參閱版本,我添加'事件,ui'參數 –