使用jQuery FullCalendar多eventsources [英] Multiple eventsources with jquery FullCalendar

查看:1059
本文介绍了使用jQuery FullCalendar多eventsources的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有如何使用与FullCalendar,即多种饲料来源的几个例子: <一href="http://stackoverflow.com/questions/1704548/how-do-i-use-multiple-sources-with-the-jquery-plugin-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
                        });
                    }
                });
            }
        }
    ],
    ...
});

这篇关于使用jQuery FullCalendar多eventsources的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆