我有一个网站,它使用分页。如何启用动态添加代码的工具提示?
我使用的工具提示使用下列插件: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