【发布时间】:2012-05-10 12:32:29
【问题描述】:
我的页面中有以下代码,该代码将 qtip 应用于图像。它通过 ajax post 显示每个图像的动态内容。但是在Thickbox/Jquery UI 对话框关闭并抛出错误后它不显示qtip:$(this).qtip is not a function
<script src="<%= Config.VirtualDir %>js/jquery.js?v=2" type="text/javascript"></script>
<script src="<%= Config.VirtualDir %>js/jquery.qtip-1.0.0-rc3.min.js?v=2" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
BindQtip();
});
function BindQtip()
{
$('image').each(function(){
$(this).live('click',function() {
var $img = $(this);
if('<%= objAdminAuth.GetUserID() %>' == $img.attr('data-uid').split('|')[0])
{
return false;
}
if ($img.data('qtip')) {return false;}
$(this).qtip({
content: 'Loading...',
style: {
border: {
width: 5,
radius: 10
},
padding: 0,
textAlign: 'center',
tip: true, // Give it a speech bubble tip with automatic corner detection
name: 'dark' // Style it according to the preset 'cream' style
},
hide: 'unfocus',
show: {
when: 'click', // Don't specify a show event
ready: true, // Show the tooltip when ready
solo: true
},
position: {
corner: {
tooltip: 'rightMiddle', // Use the corner...
target: 'bottomLeft' // ...and opposite corner
}
},
api: {
// Retrieve the content when tooltip is first rendered
onRender: function() {
var self = this;
self.content = '';
$.ajax({
url: window.location.href,
type: 'POST',
data: 'call=ajax&uid=' + $img.attr('data-uid'),
success: function(resp) {
self.updateContent(resp);
}
});
},
onContentUpdate: function() {
var self = this;
}
}
});
});
});
}
</script>
所有路径都是正确的,其他事情都很好。我错过了什么吗?
任何帮助将不胜感激。
【问题讨论】:
-
看起来您的 js 注册是在您的特定代码运行后发生的。也许尝试另一种方法(在 master 中注册)来链接您的 js 并测试是否是这样。
-
您确定 qTip 库加载正确吗?
-
将 alert() 放在 BindQtip() 之前。如果它有效,那么 ericosg 是正确的。
-
最后一行也应该是 script 而不是 scrpit =)
-
两个 JS 引用都在 master 中,函数在 child。能详细说明一下注册方法吗?
标签: jquery jquery-ui-dialog qtip thickbox