代码之家  ›  专栏  ›  技术社区  ›  karlisup

更改uidatepicker月份后,Cluetip不工作

  •  1
  • karlisup  · 技术社区  · 14 年前


    用户界面日期选择器 俱乐部 显示事件。在我更改月份之前,脚本一直在工作(按按钮<-或->)。
    主要思想是使用cluetip设置保存日期的元素的标题,并在悬停时显示和拆分行中的文本。

    编辑 example -希望这有助于理解我的问题。

    下面是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>
    

    1 回复  |  直到 14 年前
        1
  •  1
  •   Community Neeleshkumar S    7 年前

    感谢UberNeet post: 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);
    };
    

    希望这对某人有帮助。