jquery ajax和qtip动态内容
我有一个 jquery ajax 调用,我需要将结果放入 qtip 中。 我的 Ajax 通话(至 umbraco 基地)
jQuery("div.videoCardBack").mouseover(function (e) {
var getFormUrl = "/base/Popup/GetSessionPopup/" + this.id;
$.ajax({ url: getFormUrl, success: function (data) {
var result = eval("(" + data + ")");
$("#test").html("<div class=\"" + result[0].SessionVideoImageUrl + "\" style=\"width:125px;height:83px;background:url(\'xxxx.png\');margin:8px;\"> </div>" + result[0].SessionTitle + ' ' + result[0].SessionCode + ' ' + result[0].SessionDateTime + result[0].SessionAbstract);
var o = { left: e.pageX - 180, top: e.pageY - 80 };
$("#test").show(2000).offset(o);
}
});
});
The qtip
$('#verttabpanel a[rel]').each(function()
{
$(this).qtip(
{
content: {
text: '<center><img class="throbber" src="/images/animatednuts40.gif" alt="Loading..." /></center>',
url: $(this).attr('rel'),
title: {
text: 'TechReadyTV2 - ' + $(this).attr('alt'),
}
},
position: {
corner: {
target: 'bottomMiddle',
tooltip: 'topMiddle'
},
adjust: {
screen: true
}
},
show: {
delay: 900,
when: 'mouseover',
solo: true
},
hide: 'mouseout',
style: {
tip: true,
border: {
width: 0,
radius: 4
},
name: 'dark',
width: 570
}
})
});
});
I have a jquery ajax call and I need to get the results into a qtip.
My Ajax call (to umbraco base)
jQuery("div.videoCardBack").mouseover(function (e) {
var getFormUrl = "/base/Popup/GetSessionPopup/" + this.id;
$.ajax({ url: getFormUrl, success: function (data) {
var result = eval("(" + data + ")");
$("#test").html("<div class=\"" + result[0].SessionVideoImageUrl + "\" style=\"width:125px;height:83px;background:url(\'xxxx.png\');margin:8px;\"> </div>" + result[0].SessionTitle + ' ' + result[0].SessionCode + ' ' + result[0].SessionDateTime + result[0].SessionAbstract);
var o = { left: e.pageX - 180, top: e.pageY - 80 };
$("#test").show(2000).offset(o);
}
});
});
The qtip
$('#verttabpanel a[rel]').each(function()
{
$(this).qtip(
{
content: {
text: '<center><img class="throbber" src="/images/animatednuts40.gif" alt="Loading..." /></center>',
url: $(this).attr('rel'),
title: {
text: 'TechReadyTV2 - ' + $(this).attr('alt'),
}
},
position: {
corner: {
target: 'bottomMiddle',
tooltip: 'topMiddle'
},
adjust: {
screen: true
}
},
show: {
delay: 900,
when: 'mouseover',
solo: true
},
hide: 'mouseout',
style: {
tip: true,
border: {
width: 0,
radius: 4
},
name: 'dark',
width: 570
}
})
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是我为动态创建的每个新图像元素添加 qTip 所做的操作。
我已将其放在页眉上。
现在页面中每个带有
tooltipped
类的元素都将转换为 qTip。最后,每次创建新元素时我都会运行以下代码。
希望这对阅读这个问题的人有所帮助!
Here is what I've done to add qTip to every new image element I dynamically create.
I've put this on page header.
And now every element with
tooltipped
class in the page will be converted to qTip.Finally, I run the following code every time new element creates.
Hope this helps to someone reading this question!
根据您想要用数据填充的 qtip 实例,您可以执行以下操作:
var qtipAPI = $('#verttabpanel a[rel]').qtip("api");
将获取对您最初绑定到的实例的 qtip api 的引用。获得 api 引用后,您可以调用updateContent
函数,用您想要的任何内容更新 qtip 的主体。Depending on which instance of the qtip you want to populate with your data you can do the following:
var qtipAPI = $('#verttabpanel a[rel]').qtip("api");
will grab a reference to qtip api of the instance you initially bound it to. Once you have an api reference you can call theupdateContent
function to update the main body of the qtip with whatever content you want.