开发者

Cluetip doesn't work after changing uidatepicker month

开发者 https://www.devze.com 2023-01-24 05:52 出处:网络
Picked ui datepicker as calendar and used cluetip to show events. Script is working until I change the month (push button <- or ->).

Picked ui datepicker as calendar and used cluetip to show events. 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 & spli开发者_开发技巧t text in lines using cluetip.

EDIT: Here is example - hope it will help to understand my problem.

Here is the javascript code:

$(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:

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

Thanks in advance!


Thanks to UberNeet post: jQuery UI Datepicker with jQuery tipsy

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消