我有一個網站,它使用分頁。如何啓用動態添加代碼的工具提示?
我使用的工具提示使用下列插件:http://plugins.jquery.com/project/tooltip
我使用AJAX來更新一個div容器。這是代碼:
$(".page-number").live("click", function()
{
var page = parseInt($(this).html());
var progressbarValue = ((page/$("#NumberOfPages").val()) * 100);
var catId = $("#CategoryID").val();
$.ajax({
url: '@Url.Action("QuestionList")',
data: { "categoryId": catId, "page": page },
success: function (data) {
$("#question-list").html(data);
$("#progressbar").progressbar("value", progressbarValue);
$("#progresstext").html("<p>" + Math.round(progressbarValue) + "% gennemgået</p>");
EnableDisableToolTip();
}
});
});
這是爲了使功能/禁用工具提示:
<script type="text/javascript">
function EnableDisableToolTip() {
var help_text = $("#helptext_checkbox").is(':checked:');
if (help_text) {
alert("true");
$(".tooltip").qtip("enable")
}
else if (!help_text) {
alert("false");
$(".tooltip").qtip("disable");
}
}
</script>
當我加載新頁面時,我看不到任何提示,當我在與元件的鼠標懸停類=「工具提示」。另外,當我查看源代碼時,動態添加的代碼不存在。它在第一頁工作,並且class =「tooltip」的源代碼就在那裏。但不是與動態的東西。
我該如何解決這個問題?
[編輯]
的工具提示代碼:
$(".tooltip").each(function()
{
$(this).qtip({
show: 'mouseover',
hide: 'mouseout',
style: {
name: 'light', // Inherit from preset style
width: {
min: 0,
max: 250
},
},
position: {
corner: {
target: 'topMiddle',
tooltip: 'bottomLeft'
},
adjust: {
screen: true,
scroll: false
}
}
});
});
我使用代碼編輯了我的問題,以顯示工具提示,我認爲這是在$(「。tooltip」).qtip(「enable」)上觸發的。你能解釋我如何重新掃描工具提示頁面嗎? – Nanek
您需要再次在Ajax回調中調用'工具提示代碼:'。不只是啓用/禁用的代碼。 – epascarello
感謝您的幫助:) – Nanek