Im trying to make jquery ui datepicker (inline as calendar) working with tooltip. Everything is working fine, tooltip is showing until I change the month in calendar. Then tooltip stop to work. I dont know how to solve this problem and I will appreciate any help. Below is my code (I was using this script).
Thanks!
$(function() {
var specialDays = {
'2011': {
'3': {
'10': {tooltip: "Some event", className: "holiday"}
},
'4': {
'15': {tooltip: "Some another event", className: "holiday"}
}
}
};
$('#datepicker').datepicker({beforeShowDay: function(date) {
var d = date.getDate(),
m = date.getMonth()+1,
y = date.getFullYear();
if (specialDays[y] && specialDays[y][m] && specialDays[y][m][d]) {
var s = specialDays[y][m][d];
return [true, s.className, s.tooltip]; // selectable
}
return [false,'']; // non-selectable
}});
/* tool开发者_Python百科tip*/
$(".ui-datepicker-calendar tbody").tooltip();
});
Use this, it's working for me:
onChangeMonthYear: function(year, month, inst) {
setTimeout("$('.ui-datepicker-calendar tbody').tooltip()", '250');
}
Wrap the functionality of $('#datepicker').datepicker
inside of a function. Then, pass that function name to the tooltip function as a callback when the tooltip has loaded.
The reason your events are unbinded is because the HTML is changing.
Further explanation: At line 115 in the tooltip script there is an event that you can use for callback:
var initDatepicker = function(){
$('#datepicker').datepicker({beforeShowDay: function(date) {
// Your code...
}});
};
$('.ui-datepicker-calendar tbody').tooltip({
// On tooltip open, init the datepicker
open: initDatepicker
});
精彩评论