Jquery 第一次鼠标悬停时工具提示不显示
我正试图找出使用tooltipster插件触发动态工具提示的最佳方法。基本上,我有一个脚本,它循环出一组带有ID的元素。我通过jquery从Jquery 第一次鼠标悬停时工具提示不显示,jquery,ajax,mouseover,tooltipster,Jquery,Ajax,Mouseover,Tooltipster,我正试图找出使用tooltipster插件触发动态工具提示的最佳方法。基本上,我有一个脚本,它循环出一组带有ID的元素。我通过jquery从.hover事件中获取ID,并将其传递到运行ajax调用的tooltipster小部件中,为该ID提取适当的数据。除了第一个.hover事件外,一切正常,因为最初没有与元素关联的tooltipster小部件 我认为我需要的(我只是不知道如何去做)是一个可靠的方法来检查是否有与元素关联的tooltipster小部件,如果没有,在我现有的脚本中触发鼠标悬停 我的
.hover
事件中获取ID,并将其传递到运行ajax调用的tooltipster小部件中,为该ID提取适当的数据。除了第一个.hover
事件外,一切正常,因为最初没有与元素关联的tooltipster小部件
我认为我需要的(我只是不知道如何去做)是一个可靠的方法来检查是否有与元素关联的tooltipster小部件,如果没有,在我现有的脚本中触发鼠标悬停
我的想法是:
if(!$(this).tooltipster()){$(this).trigger('mouseover');}
下面是函数:
$(document).ready(function() {
$('.tooltip').hover(function(){
var content = $(this).attr("id");
if(!$(this).tooltipster()){$(this).trigger('mouseover');}
$(this).tooltipster({
animation: 'fade',
delay: 0,
speed: 250,
theme: '.newtooltip',
content: '<img src="images/ajaxcircle.gif" width="16" height="16" />',
functionBefore: function (origin, continueTooltip) {
continueTooltip();
if (origin.data('ajax') !== 'cached') {
$.ajax({
type: 'GET',
url: 'datagrab.html',
data: { ID: content},
success: function (data) {
origin.tooltipster('update', data).data('ajax ', 'cached');
}
});
}
}
});
});
});
$(文档).ready(函数(){
$('.tooltip').hover(函数(){
var content=$(this.attr(“id”);
if(!$(this.tooltipster()){$(this.trigger('mouseover');}
$(此).tooltipster({
动画:“淡入淡出”,
延迟:0,
速度:250,
主题:“.newtooltip”,
内容:“”,
functionBefore:函数(原点,continueTooltip){
continueTooltip();
if(origin.data('ajax')!='cached'){
$.ajax({
键入:“GET”,
url:'datagrab.html',
数据:{ID:content},
成功:功能(数据){
origin.tooltipster('update',data.data('ajax','cached');
}
});
}
}
});
});
});
我正在做类似的事情,问题是我第一次将鼠标悬停在对象上时,tooltipster尚未初始化。第二次,它是我第一次尝试初始化的
解决方案是在页面加载时初始化tooltipster
jQuery(document).ready(function(){
/**Initialize all instances of tooltipster **/
jQuery.fn.tooltipster('setDefaults', {
theme: 'tooltipster-default'
});
}
);
我正在做类似的事情,问题是我第一次将鼠标悬停在对象上时,tooltipster尚未初始化。第二次,它是我第一次尝试初始化的 解决方案是在页面加载时初始化tooltipster
jQuery(document).ready(function(){
/**Initialize all instances of tooltipster **/
jQuery.fn.tooltipster('setDefaults', {
theme: 'tooltipster-default'
});
}
);
您可以使用以下选项:
var tooltipInstance;
$("body").on('mouseover', '.tooltip:not(.tooltipstered)', function({
tooltipInstance = $(this).tooltipster({ ... });
tooltipInstance.tooltipster('open');
});
就你而言:
$(document).ready(function(){
var tooltipInstance;
$("body").on('mouseover', '.tooltip:not(.tooltipstered)', function(){
var content = $(this).attr("id");
tooltipInstance = $(this).tooltipster({
animation: 'fade',
delay: 0,
speed: 250,
theme: '.newtooltip',
content: '<img src="images/ajaxcircle.gif" width="16" height="16" />',
functionBefore: function (origin, continueTooltip) {
continueTooltip();
if (origin.data('ajax') !== 'cached') {
$.ajax({
type: 'GET',
url: 'datagrab.html',
data: { ID: content},
success: function (data) {
origin.tooltipster('update', data).data('ajax ', 'cached');
}
});
}
}
});
tooltipInstance.tooltipster('open');
});
});
$(文档).ready(函数(){
var工具提示;
$(“body”)。在('mouseover','上。工具提示:不是(.tooltipster)',函数(){
var content=$(this.attr(“id”);
tooltipInstance=$(此).tooltipster({
动画:“淡入淡出”,
延迟:0,
速度:250,
主题:“.newtooltip”,
内容:“”,
functionBefore:函数(原点,continueTooltip){
continueTooltip();
if(origin.data('ajax')!='cached'){
$.ajax({
键入:“GET”,
url:'datagrab.html',
数据:{ID:content},
成功:功能(数据){
origin.tooltipster('update',data.data('ajax','cached');
}
});
}
}
});
tooltipInstance.tooltipster('open');
});
});
您可以使用以下功能:
var tooltipInstance;
$("body").on('mouseover', '.tooltip:not(.tooltipstered)', function({
tooltipInstance = $(this).tooltipster({ ... });
tooltipInstance.tooltipster('open');
});
就你而言:
$(document).ready(function(){
var tooltipInstance;
$("body").on('mouseover', '.tooltip:not(.tooltipstered)', function(){
var content = $(this).attr("id");
tooltipInstance = $(this).tooltipster({
animation: 'fade',
delay: 0,
speed: 250,
theme: '.newtooltip',
content: '<img src="images/ajaxcircle.gif" width="16" height="16" />',
functionBefore: function (origin, continueTooltip) {
continueTooltip();
if (origin.data('ajax') !== 'cached') {
$.ajax({
type: 'GET',
url: 'datagrab.html',
data: { ID: content},
success: function (data) {
origin.tooltipster('update', data).data('ajax ', 'cached');
}
});
}
}
});
tooltipInstance.tooltipster('open');
});
});
$(文档).ready(函数(){
var工具提示;
$(“body”)。在('mouseover','上。工具提示:不是(.tooltipster)',函数(){
var content=$(this.attr(“id”);
tooltipInstance=$(此).tooltipster({
动画:“淡入淡出”,
延迟:0,
速度:250,
主题:“.newtooltip”,
内容:“”,
functionBefore:函数(原点,continueTooltip){
continueTooltip();
if(origin.data('ajax')!='cached'){
$.ajax({
键入:“GET”,
url:'datagrab.html',
数据:{ID:content},
成功:功能(数据){
origin.tooltipster('update',data.data('ajax','cached');
}
});
}
}
});
tooltipInstance.tooltipster('open');
});
});
请显示包含ID元素的html代码。请显示包含ID元素的html代码。