简体   繁体   English

JavaScript日历插入变量

[英]javascript calendar insert variable

I'm using a calendar script to show event dates. 我正在使用日历脚本来显示事件日期。 I have my events in a variable file called eventdates . 我的事件存储在名为eventdates的变量文件中。

I want to include eventdates here: 我想在这里包括eventdates

$(document).ready(function () {
    // page is now ready, initialize the calendar...
    $('#calendar').fullCalendar({
        events: [
             eventdates;
        ]
        // put your options and callbacks here
    })
});

But that's not working. 但这不起作用。 I don't know how to fix that because I grab the events from an array. 我不知道如何解决此问题,因为我从数组中获取事件。

Remove the semicolon: 删除分号:

$(document).ready(function () {
    // page is now ready, initialize the calendar...
    $('#calendar').fullCalendar({
        events: [
             eventdates
        ]
        // put your options and callbacks here
    })
});

or use 或使用

$(document).ready(function () {
    // page is now ready, initialize the calendar...
    $('#calendar').fullCalendar({
        events: eventdates
        // put your options and callbacks here
    })
});

if eventdates is already an array. 如果eventdates已经是一个数组。

You'll have to make sure that your events are stored as an array and then you can use 您必须确保将events存储为数组,然后才能使用

$(document).ready(function () {
    // page is now ready, initialize the calendar...
    $('#calendar').fullCalendar({
        events: eventdates
    })
});

take a look at this link for proper usage 看看此链接的正确用法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM