1


选择ui datepicker作为日历并使用线索提示来显示事件。脚本一直在工作,直到我更改月份(按钮 <- 或 ->)。
主要思想是为保存日期和悬停显示的元素设置标题,并使用线索提示将文本拆分为行。

编辑:这是示例-希望它有助于理解我的问题。

这是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代码:

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

提前致谢!

4

1 回答 1

1

感谢 UberNeet 帖子: jQuery UI Datepicker with jQuery Tipsy

找到了答案。

// 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);
};

希望这会对某人有所帮助。

于 2010-11-08T00:12:08.533 回答