2

我拥有的是一个带有 12 个标签的标签页(每个标签都是一年中的一个月)。我需要的是当我加载 jquery 日历、foreach 选项卡、日历以切换到分配的月份。(例如,当我单击并加载一月份的页面时,日历显示一月份的天数,依此类推)。

4

3 回答 3

5

演示:http ://so.lucafilosofi.com/jquery-full-calendar

JS:

        $(function() {
            // build months anchors list
            monthsList('#months-list');

            // inizialize calendar
            $('#calendar').fullCalendar({});

            $(document).on('click', '#months-list a', function() {
                // get month from month anchor hash
                var month = this.hash.substring(1);
                // go to new month
                $('#calendar').fullCalendar('gotoDate', goToMonth(month));
                return false;
            });

            function goToMonth(month) {
                var date = new Date();
                var d = date.getDate();
                var m = month !== undefined ? parseInt(month, 0) : date.getMonth();
                var y = date.getFullYear();
                return new Date(y, m, d);
            }

            function monthsList(element) {
                var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
                for (var m = 0; m < monthNames.length; m++) {
                    $(element).append('<li><a href="#' + m + '">' + monthNames[m] + '</a></li>');
                }
            }

        });

HTML:

    <ul id="months-list"></ul>
    <div id='calendar'></div>
于 2010-03-17T16:34:08.717 回答
4

您是否查看了文档页面?该函数接受 2 个必需参数和 2 个可选参数。

.fullCalendar( 'gotoDate', year [, month, [ date  ]] )

因此,要将日历设置为 2010 年 4 月,您可以使用如下内容:

.fullCalendar( 'gotoDate', 2010, 5)

请注意,月份是从 0 开始的,因此 April=3。

于 2010-03-17T15:37:44.607 回答
2

你读过API吗?看来,如果您想显示 2010 年 7 月,您可以致电:

yourCal.fullCalendar('gotoDate',2010,6);

我的回答很简单,因为我不知道你已经尝试过做什么。

于 2010-03-17T15:34:26.033 回答