弹出窗口中的jquery周日历

时间:2013-04-04 04:54:25

标签: jquery popup jquery-week-calendar

我正在尝试

我正在尝试实施一个事件管理网站,在该网站中,当点击链接时,会出现一个弹出窗口,其中包含显示其中事件的日历。 我在这里使用 jquery周历

要求

我在这里面临的问题是,首次点击链接时第一次日历工作正常。但是当我再次点击它而没有页面刷新时,日历不会显示。当我检查它显示错误

TypeError: options.shortDays is undefined

...options.useShortDayNames ? options.shortDays[date.getDay()] : options.longDays[d...jquery.weekcalendar.js (line 3098)

我该如何解决这个问题?

日历仅在页面加载后第一次起作用。

脚本

 <a href="#" data-reveal-id="reveal_popup" onclick="calendarpop('MT','1');" data-closeonbackgroundclick="false" data-dismissmodalclass="close-reveal-modal">due_today</a>

 <div id="reveal_popup" class="reveal-modal">
   <div id="calendar_popup"></div>
   <a class="close-reveal-modal">&#215;</a>
 </div>


 function calendarpop(cat,typ) {

    if(typ == 1){
        var days = 1;
    }
    else if(typ==2){
        var days = 2;
    }
    else if(typ==3){
        var days = 7;
    }

    var $calendar = $('#calendar_popup').weekCalendar({
        timeslotsPerHour: 4,
        scrollToHourMillis : 0,
        height: function($calendar){
            return $(window).height() - $('h1').outerHeight(true);
        },
        eventRender : function(calEvent, $event) {
            if (calEvent.end.getTime() < new Date().getTime()) {
                $event.css('backgroundColor', '#aaa');
                $event.find('.wc-time').css({
                    backgroundColor: '#999',
                    border:'1px solid #888'
                });
            }
        },

        data : function(start, end, callback) {
            $.getJSON(
            site_url()+'/event/eventpop/'+cat+'/'+typ,
            '',
            function(result) {
                callback(result);
            }
        );
        },
        allowCalEventOverlap : true,
        overlapEventsSeparate: true,
        showAsSeparateUser: false,
        displayOddEven: true,
        displayFreeBusys: true,
        daysToShow: days,
        buttons: false,
        headerSeparator: ' ',
        useShortDayNames: true,
        firstDayOfWeek: $.datepicker.firstDay,
        shortDays: $.datepicker.dayNamesShort,
        longDays: $.datepicker.dayNames,
        shortMonths: $.datepicker.monthNamesShort,
        longMonths: $.datepicker.monthNames,
        businessHours :{
            start: 6, 
            end: 22, 
            limitDisplay: true
        },
        dateFormat: 'd F Y'
    });

}

1 个答案:

答案 0 :(得分:0)

你能去这里吗? http://jsfiddle.net/83mMH/14/

请将URL添加到JSON数据中,然后我们可以从那里进行调试。

我还发现将所有JS外部化更加可维护,包括从html中删除onclick =“”并改为使用jQuery事件监听器。

jQuery(document).ready(function($)
                       {
$('#reveal_popup').click(function()
{
  calendarpop('MT','1');
});
var calendarpop = function calendarpop(cat,typ) 
{
var days;
    if(typ == 1){
        days = 1;
    }
    else if(typ==2){
        days = 2;
    }
    else if(typ==3){
        days = 7;
    }

    var $calendar = $('#calendar_popup').weekCalendar({
        timeslotsPerHour: 4,
        scrollToHourMillis : 0,
        height: function($calendar){
            return $(window).height() - $('h1').outerHeight(true);
        },
        eventRender : function(calEvent, $event) {
            if (calEvent.end.getTime() < new Date().getTime()) {
                $event.css('backgroundColor', '#aaa');
                $event.find('.wc-time').css({
                    backgroundColor: '#999',
                    border:'1px solid #888'
                });
            }
        },

        data : function(start, end, callback) {
            $.getJSON(
            site_url()+'/event/eventpop/'+cat+'/'+typ,
            '',
            function(result) {
                callback(result);
            }
        );
        },
        allowCalEventOverlap : true,
        overlapEventsSeparate: true,
        showAsSeparateUser: false,
        displayOddEven: true,
        displayFreeBusys: true,
        daysToShow: days,
        buttons: false,
        headerSeparator: ' ',
        useShortDayNames: true,
        firstDayOfWeek: $.datepicker.firstDay,
        shortDays: $.datepicker.dayNamesShort,
        longDays: $.datepicker.dayNames,
        shortMonths: $.datepicker.monthNamesShort,
        longMonths: $.datepicker.monthNames,
        businessHours :{
            start: 6, 
            end: 22, 
            limitDisplay: true
        },
        dateFormat: 'd F Y'
    });
}
});