[英]Jquery tooltip ON event not firing after change of datepicker month
我已經向jquery datepicker插件添加了一些基本的工具提示,但是在更改月份之后,事件不再綁定到其選擇器。 如何在月份更改時重新綁定這些事件?
下面是我正在使用的簡化版本。
<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>
嘗試像這樣綁定您的事件:
$(document).on("mouseenter",".ui-state-default",function(e){
//Your stuff
});
有關更多說明,請參見此答案 !
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.