QTip 显示在错误的位置
我正在尝试显示 qtip 以响应用户单击全日历中的某一天。
这在 Chrome 中工作正常,但在 Firefox 和 Internet Explorer 中,qtip 在错误的位置打开。
这可以通过点击不同的日期来看到,有时qtip会在错误的位置打开,有时会打开然后立即关闭。
当不使用 $(this).qtip('destroy')
以及定义 solo: false
时,可以观察到此行为。
当您第一次在单元格内单击时,似乎会发生这种情况,如果您随后在同一单元格内移动鼠标并再次单击,qtip 将显示在正确的位置。该单元格将继续正常工作,直到页面刷新。
完整示例位于 https://gist.github.com/1467702
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="fullcalendar.css">
<link rel="stylesheet" type="text/css" href="jquery.qtip.css">
</head>
<body>
<div id="calendar"></div>
<script type="text/javascript" src="jquery-1.6.3.js"></script>
<script type="text/javascript" src="jquery.qtip.js"></script>
<script type="text/javascript" src="fullcalendar.js"></script>
<script type="text/javascript">
$(function() {
$('#calendar').fullCalendar({
dayClick: dayclick
});
});
function dayclick(date, allday, jsevent) {
var randomContent = new Date().valueOf().toString();
$(this).qtip({
overwrite: true,
content: {
text: randomContent,
title: {
text: 'Testing',
button: 'Close'
}
},
show: {
solo: true,
event: 'click',
ready: true
},
style: {
tip: true
},
position: {
viewport: $(window),
target: 'mouse',
my: 'bottom center',
at: 'top center',
adjust: {
mouse: false
}
},
hide: {
fixed: true,
delay: 300
},
events: {
hide: function () {
$(this).qtip('destroy');
}
}
}, jsevent);
}
</script>
</body>
</html>
I'm trying to display a qtip in response to the user clicking on a day in fullcalendar.
This works correctly in chrome but firefox and internet explorer the qtip opens in the wrong location.
This can be seen by clicking on different days, sometimes the qtip will open at the wrong location, other times it will open then immediately close.
This behaviour can be observed when not using $(this).qtip('destroy')
and when solo: false
is defined.
It seems to happen the first time you click inside a cell, if you then move the mouse within the same cell and click again the qtip displays at the correct position. That cell well then continue to work correctly until the page is refreshed.
The full example is available at https://gist.github.com/1467702
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="fullcalendar.css">
<link rel="stylesheet" type="text/css" href="jquery.qtip.css">
</head>
<body>
<div id="calendar"></div>
<script type="text/javascript" src="jquery-1.6.3.js"></script>
<script type="text/javascript" src="jquery.qtip.js"></script>
<script type="text/javascript" src="fullcalendar.js"></script>
<script type="text/javascript">
$(function() {
$('#calendar').fullCalendar({
dayClick: dayclick
});
});
function dayclick(date, allday, jsevent) {
var randomContent = new Date().valueOf().toString();
$(this).qtip({
overwrite: true,
content: {
text: randomContent,
title: {
text: 'Testing',
button: 'Close'
}
},
show: {
solo: true,
event: 'click',
ready: true
},
style: {
tip: true
},
position: {
viewport: $(window),
target: 'mouse',
my: 'bottom center',
at: 'top center',
adjust: {
mouse: false
}
},
hide: {
fixed: true,
delay: 300
},
events: {
hide: function () {
$(this).qtip('destroy');
}
}
}, jsevent);
}
</script>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不会以这种方式工作。因为您没有在 dayClick 函数中保留元素。
如果您的要求适合您,请尝试这种方式!
});
请参阅此
Fiddle
This wont work in this way. because you don't have the hold of element inside the dayClick Function.
Try in this way, if your requirement suits to you!
});
Refer this
Fiddle
亲爱的朋友,你必须添加 qtip css 链接,然后它才能完美工作......
Dear friend you have to add qtip css link then it will work perfectly....