jQuery qTip回调不工作
我对表中的项目调用了qTipjQuery qTip回调不工作,jquery,jquery-plugins,qtip,Jquery,Jquery Plugins,Qtip,我对表中的项目调用了qTip $('#orders_table a[rel]').each(function (){ $(this).click(function(){ return false; }); $(this).qtip({ content: { // Set the text to an image HTML
$('#orders_table a[rel]').each(function (){
$(this).click(function(){
return false;
});
$(this).qtip({
content: {
// Set the text to an image HTML string with the correct src URL to the loading image you want to use
text: 'Loading...',
url: $(this).attr('rel'),
// Use the rel attribute of each element for the url to load
title: {
text: 'Order Number ' + $(this).text(),
// Give the tooltip a title using each elements text
button: 'Close' // Show a close link in the title
}
},
position: {
corner: {
target: 'bottomMiddle',
// Position the tooltip above the link
tooltip: 'topMiddle'
},
adjust: {
screen: true // Keep the tooltip on-screen at all times
}
},
show: {
when: 'click',
solo: true // Only show one tooltip at a time
},
hide: 'unfocus',
style: {
tip: true,
// Apply a speech bubble tip to the tooltip at the designated tooltip corner
border: {
width: 0,
radius: 4
},
name: 'light',
// Use the default light style
width: 570 // Set the tooltip width
}
})
});
然后我有以下回调函数:
$('#orders_table a[rel]').each(function (){
$(this).qtip({
api: {
onContentLoad:function() {
$('#select').change(function(){
alert('test');
});
}
}
})
});
qTip正在加载动态内容。该动态内容有一个id为“select”的选择框
但出于某种原因,它似乎没有在qTip加载动态内容后调用该函数
有什么想法吗?我尝试了onRender和onContentUpdate,这似乎不合适
谢谢大家! 我不能100%确定这是否与我们遇到的问题相同,但当您将qTip的锚点设置为ajax链接时,ajax链接会触发自身的重新渲染,qTip最终会在DOM中不扎根,回调和计时器停止工作
我们通过将qTip锚定到一个near-by元素来解决这个问题。希望这能有所帮助。问题不在于回调正在运行,而在于加载具有特定ID的内容。ID在页面中是唯一的,因此在此处使用类,这样当加载多个qTip时,它不会使唯一ID规则无效(导致
#select
返回这些元素中的第一个,而不是所有元素)
您可以通过将选择更改为拥有一个类(如果它是内容中唯一的
),如下所示:
<select class="mySelect">
$('#orders_table a[rel]').each(function (){
$(this).qtip({
api: {
onContentLoad:function() {
this.elements.content.find('select.mySelect').change(function() {
alert('test');
});
}
}
});
});
此外,如果出于其他原因不需要循环,可以将其缩短为:
$('#orders_table a[rel]').qtip({
api: {
onContentLoad:function() {
this.elements.content.find('select.mySelect').change(function() {
alert('test');
});
}
}
});
事实上,它需要一种特殊的方式 不同控件的ID。因此,尝试不同的方法 ID意味着传递一些参数并生成ID 创建控件时会有所不同 动态地
它可能会解决您的问题。这似乎不起作用。。。ID应该可以,因为一次只加载一个qTip,所以它基本上是唯一的。然而,我把它改成了一个类,尝试了两种方法。。不走运!所以我将qTip附加到一组锚上,锚上有ref。是否将其附加到其他元素?这将如何工作?我们必须编写一些代码来产生类似的东西;例如,我们使用它来显示当用户将一个元素放入购物篮时,triggerTooltip方法只需在传递的元素上创建一个工具提示(我相信是一个近范围),然后我们使用定位和角设置使其看起来像是附加到购物车图标上。这不是一个理想的解决方案,但恐怕这是我们发现的唯一一个与ajax兼容的解决方案。