[英]Jquery tooltip ON event not firing after change of datepicker month
I've added some basic tooltips to the jquery datepicker plugin but after I change the month the events are no longer bound to their selectors. 我已经向jquery datepicker插件添加了一些基本的工具提示,但是在更改月份之后,事件不再绑定到其选择器。 How can I rebind these events on month change?
如何在月份更改时重新绑定这些事件?
A cut down version of what I'm working with is below. 下面是我正在使用的简化版本。
<script>
$(function() {
$("#scene").datepicker();
var evtd = {
March312013: {title: "Ladies Night"},
March302013: {title: "Lilly Allen Tribute Band"}
}
$(".ui-state-default").on("mouseenter", function(e) {
var month = $(".ui-datepicker-month").text();
var year = $(".ui-datepicker-year").text();
var day = $(this).text();
ix = month + day + year;
if(typeof(evtd[ix])!="undefined")
{
var html = '<h5>'+evtd[ix]["title"]+'</h5>';
var eleft = $(this).position().left;
var etop = $(this).position().top;
$("#tt").html(html).css({
left: Math.max(eleft-($(this).width()/2),0),
top: Math.max(etop+$(this).height()+7,0)
}).show();
}
}).mouseleave(function(){
$("#tt").hide();
});
});
</script>
<style>
.nm{
margin:0;
}
#tt{
max-width:250px;
position:absolute;
border:1px solid black;
background-color:#E9EAEE;
padding:8px;
display:none;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
font-family:Trebuchet MS,Tahoma,Verdana,Arial,sans-serif;
}
</style>
<div id="scene">MobeScene Events</div>
<div id="tt"></div>
Try to bind your event like this : 尝试像这样绑定您的事件:
$(document).on("mouseenter",".ui-state-default",function(e){
//Your stuff
});
See this answer for further explications! 有关更多说明,请参见此答案 !
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.