使用jQuery FullCalendar多eventsourcesjQuery、FullCalendar、eventsources

由网友(素顔爲誰妝)分享简介:我知道有如何使用与FullCalendar,即多种饲料来源的几个例子:Stackoverflow帖子 I know there are a few examples of how to use multiple feed sources with FullCalendar, ie:Stackoverflow po...

我知道有如何使用与FullCalendar,即多种饲料来源的几个例子: Stackoverflow帖子

I know there are a few examples of how to use multiple feed sources with FullCalendar, ie: Stackoverflow post

插件文档

然而,他们没有展示如何使用多个饲料来源有更多的阿贾克斯信息,如类型,数据等。

However, none of them show how to use multiple feed sources with additional ajax info such as type, data, etc.

我想使用多个饲料来源,但不能让它开始工作。这是我的code:

I am trying to use multiple feed sources but can't get it to work. Here is my code:

eventSources: [
    'json-schedule.php',
    'json-events.php'
],

    type: 'POST',
    data: {
        //  custom_param1: 'something', 
    },
    error: function() {
        alert('there was an error while fetching events!');
    },
    success: function() {
    },

在什么地方类型,数据,错误和放大器;成功份与多于一个的数据源去吗?没有一个例子,我发现表明。

Where does the type, data, error & success parts go with more than one data source? None of the examples I've found show that.

推荐答案

试试这个方法:

$('#calendar').fullCalendar({
    ...
    eventSources: [
        // your JSON event source
        {
            url: '/myfeed.php', // use the `url` property
            color: 'yellow',    // an option!
            textColor: 'black'  // an option!
        },

        // your ajax event source
        {
            events: function(start, end, callback) {
                $.ajax({
                    url: 'myxmlfeed.php',
                    dataType: 'xml',
                    data: {
                        // our hypothetical feed requires UNIX timestamps
                        start: Math.round(start.getTime() / 1000),
                        end: Math.round(end.getTime() / 1000)
                    },
                    success: function(doc) {
                        var events = [];
                        $(doc).find('event').each(function() {
                        events.push({
                            title: $(this).attr('title'),
                            start: $(this).attr('start') // will be parsed
                        });
                    }
                });
            }
        }
    ],
    ...
});
阅读全文

相关推荐

最新文章