1

我在http://jsfiddle.net/paul724/HXb6v/上找到了一些 jquery 事件日历示例,它工作正常,直到我更改月份 - 鼠标悬停停止工作。只有 onChange 有效。

例如至少有一个错误: $("a").mouseover它应该是$(".ui-state-default").mouseover

我在 jquery datepicker ui 中发现了类似的问题- 在下一个前一个之后失去悬停,但这对我没有帮助。

请问你能帮帮我吗 ?

非常感谢

4

1 回答 1

0

问题在于缺少功能:

onChangeMonthYear: function () {
    setTimeout(function() {
        updateRefs();
    }, 0);  
}

整个代码:

<div id="dialog"></div>
<div id="datepicker"></div>

<script type="text/javascript">
    $(document).ready(function() {
        var activeDays = [1,4,10,21,22,23,27,28,30];
        $('#datepicker').datepicker({
            dateFormat: 'yy-m-d',
            inline: true,

            //show only selected days
            beforeShowDay: function(date) {
                var hilight = [false,''];
                if ( activeDays.indexOf( date.getDate() ) > -1) {
                    hilight = [true,'isActive'];
                }
                return hilight;
            }, 
            //update references after month change
            onChangeMonthYear: function () {
                setTimeout(function() {
                    updateRefs();
                }, 0);  
            },

            /* onSelect freezes the dialog box and populates with a link
            want to populate the dialog on hover and then freeze so that link can be followed*/    
            onSelect: function(date) {
                $('#dialog').dialog({ autoOpen: false });
                var detail = $(".ui-state-default.ui-state.hover").html();
                $('#dialog').attr('title', "changed");
                $('#dialog').html( '<a href="http://www.xxx/addoreditevent.php?id=1">' + "<span style='color: #7f7fff; font-weight: lighter;'>" + '(edit)  ' + ' date: ' + date + ' </span></a>');
                //now open the dialog
                $('#dialog').dialog('open');
                }
        });

        //create dialogue
        //title could be set once, and before createing dialogue
        $('#dialog').attr('title', 'events');
        var dlg = $('#dialog').dialog({
            autoOpen: false,
            draggable: false,
            resizable: false,
            width: 650
        });


        function updateRefs() {
            $(".ui-state-default").mouseover(function() {
              dlg.dialog("open");
            //open dialogue  
            }).mousemove(function(event) {
              dlg.dialog("option", "position", {
                my: "left top",
                at: "right bottom",
                of: event,
                offset: "20 20"
              });
              //write dialogue text, html could be set dynamicaly, title not !
              var dateF = $(this).text()+"."+$(".ui-datepicker-month",$(this).parents()).text()+"."+$(".ui-datepicker-year",$(this).parents()).text();  
              $('#dialog').html( '<a href="http://www.xxx/addoreditevent.php?id=2">' + "<span style='color: #7f7fff; font-weight: lighter;'>" + '(edit)  ' + 'text: ' + $(this).text() + 'date: ' + dateF + ' </span></a>');
            //close dialogue  
            }).mouseout(function() {
                dlg.dialog("close");
            });
        }

        updateRefs();
        }); 

</script>
于 2013-05-13T15:29:11.867 回答