我试图通过ajax显示qtip popup但没有成功。我得到了以下代码,但似乎无法检测出错了。非常感谢帮助。
<script type="text/javascript">
$(document).ready(function()
{
$('.tiplink').qtip({
content:{
var id = $(this).attr('rel');
text: '<img class="" src="../images/loader.gif" alt="Loading..." />',
ajax:{
url: 'pops.php',
type: 'POST',
loading: false,
data: 'id=' + id
}
},
show: 'mouseover', // Show it on mouseover
hide: {
delay: 200,
fixed: true // We'll let the user interact with it
},
style: {
classes: 'ui-tooltip-light ui-tooltip-shadow',
width: 290
}
});
});
</script>
<a href="#" class="tiplink" rel='1'>show me the popup1!</a>
<a href="#" class="tiplink" rel='2'>show me the popup2!</a>
<a href="#" class="tiplink" rel='3'>show me the popup3!</a>
答案 0 :(得分:1)
我有类似的问题;它似乎与 $(&#39; .myclass&#39;)。qtip({})不能引用多个元素这一事实有关。如果它(例如你的例子)你需要在每个(function())块中包装qtip()调用...
关于您的示例,以下内容应解决您的问题:
$(document).ready(function()
{
// the each() call I was explaining above this code example
$('.tiplink').each(function(){
// Extract your variables here:
var $this = $(this);
var id = $this.attr('rel');
// Now make your qtip() call
$this.qtip({
content:{
text: '<img class="" src="../images/loader.gif" alt="Loading..." />',
ajax:{
url: 'pops.php',
type: 'POST',
loading: false,
data: 'id=' + id
}
},
show: 'mouseover', // Show it on mouseover
hide: {
delay: 200,
fixed: true // We'll let the user interact with it
},
style: {
classes: 'ui-tooltip-light ui-tooltip-shadow',
width: 290
}
});
}); // end each(function()) call
});
答案 1 :(得分:0)