简体   繁体   English

更改uidatepicker月后,Cluetip不起作用

[英]Cluetip doesn't work after changing uidatepicker month


Picked ui datepicker as calendar and used cluetip to show events. 选择ui datepicker作为日历,并使用cluetip显示事件。 Script is working until I change the month (push button <- or ->). 直到我更改月份(按下按钮<-或->)之前,脚本一直有效。
Main idea was to set title to the element that holds date and on hover show & split text in lines using cluetip. 主要思想是将标题设置为保存日期的元素,并在悬停时使用cluetip在行中显示和拆分文本。

EDIT : Here is example - hope it will help to understand my problem. 编辑 :这是示例 -希望它将有助于理解我的问题。

Here is the javascript code: 这是JavaScript代码:

$(document).ready(function() {
var dates =[ // adding events
[new Date(2010,8,01),new Date(2010,8,03),"Event1 | text | next line"]
];

$('#calendar').datepicker({ 
beforeShowDay: highlightEvents,
});

function highlightEvents(date) {
for (var i = 0; i < dates.length; i++) {
if (dates[i][0] <= date && dates[i][2] >= date) {
return [true, 'odd', dates[i][2]]; } // odd == style 
}

$('td.odd').cluetip({ // cluetip main function
splitTitle: '|',
cluetipClass: 'jtip',
arrows: true, 
dropShadow: true,
});
});

Html code: HTML代码:

<div id="calendar"></div>

Thanks in advance! 提前致谢!

Thanks to UberNeet post: jQuery UI Datepicker with jQuery tipsy 感谢UberNeet的帖子: 带有jQuery Tipsy的jQuery UI Datepicker

Found the answer. 找到了答案。

// Because the the event `onChangeMonthYear` get's called before updating 
// the items, we'll add our code after the elements get rebuilt. We will hook 
// to the `_updateDatepicker` method in the `Datepicker`.
// Saves the original function.
var _updateDatepicker_o = $.datepicker._updateDatepicker;
// Replaces the function.
$.datepicker._updateDatepicker = function(inst){ 
   // First we call the original function from the appropiate context.
   _updateDatepicker_o.apply(this, [inst]); 
   // No we can update the Tipsys.
   addTipsys(inst.drawYear, inst.drawMonth+1, inst.id);
};

Hope this will help someone. 希望这会帮助某人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM