rem*_*dix 7 jquery user-interface datepicker tooltip
有关如何在jQuery的UI Datepicker 上实现技巧工具提示的任何想法?基本上我想在用户在Datepicker中的特定日期移动时获得工具提示.Datepicker将以内联方式显示并始终可见.
谢谢!
听起来很酷,
这是我的解决方案.阅读评论.
(function($){
/** 
 * Returns a dictionary, where the keys are the day of the month, 
 * and the value is the text.
 * @param year - The year of the events.
 * @param month - The month of the events.
 * @param calendarID - Events for a specific calendar.
 */
function getMonthEvents(year, month, calendarId){
  return {11: "My birthday.", 23: "My anniversary" };
}
// Receives January->1
function addTipsys(year, month, calendarId){
   var theEvents = getMonthEvents(year, month, calendarId);
   var theDateLinks = $('#' + calendarId + ' .ui-datepicker-calendar a');
   for(eventDay in theEvents){
      // Minus one, because the date in the tipies are regular dates (1-31)
      // and the links are 0-based.
      theDateLinks.eq(eventDay-1)  // select the right link
         .attr('original-title', theEvents[eventDay])  // set the text
         .tipsy();   // init the tipsy, set your properties.
   }
}
// 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);
};
// Finally the calendar initializer.
$(function(){
   // Creates the date picker, with your options.
   $("#datepicker").datepicker();
   // Gets the date and initializes the first round of tipsies.
   var currentDate = $('#datepicker').datepicker('getDate');
   // month+1 because the event considers January->1
   // Last element is null, because, it doesn't actualy get used in the hanlder.
   addTipsys(currentDate.getYear(), currentDate.getMonth()+1, 'datepicker');
});
})(jQuery);
不便之处:
该_updateDatepicker方法获取的也称,当用户选择了一天形成可见的一个月,或当你通过设置一个日期datepicker('setDate', theDate),这可能是一个有点低效.
它依赖于Datepicker的私有函数,如果在将来的版本中他们决定更改它的功能,或者更改名称,这段代码就会破坏.虽然由于功能的性质,我不认为很快就会发生这种情况.
注意: 
我的第一种方法是挂钩onChangeMonthYear事件ui.datepicker,但因为事件被触发,在更换日历中的日期之前,该addTipsys方法会将提示添加到即将被清除的日历日期.因此需要addTipsys在元素刷新后调用事件.
EASY HACK: 
将方法挂钩到onChangeMonthYear日历事件中,然后执行setTimeout调用tipsy.需要进行一些验证.
| 归档时间: | 
 | 
| 查看次数: | 3825 次 | 
| 最近记录: |