【问题标题】:how to use the EventOrder attribute in fullcalendar jquery plugin如何在fullcalendar jquery插件中使用EventOrder属性
【发布时间】:2015-09-14 16:49:47
【问题描述】:

我想为 fullcalendar jquery 插件使用 eventOrder 属性,但我找不到任何如何设置属性的示例。 我添加了我想使用的非标准字段属性、描述。 如何将此属性设置为 eventOrder? 这是我的事件当前的显示方式:

$('#calendar').fullCalendar({
    header:
    {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },
    titleFormat: {month: 'MMMM'},   
    defaultView: 'month',
    events: function (start, end, timezone, callback) {
        $.ajax({
            type: "POST",
            url: '@Url.Action("GetAllEvents", "Home")',
            // data: "{'userID':'" + $('#<%= hidUserID.ClientID %>').val() + "'}",  //this is what I use to pass who's calendar it is
            //completely take out 'data:' line if you don't want to pass to webmethod - Important to also change webmethod to not accept any parameters
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (doc) {
                var events = [];                     
                $(doc).each(function () { 
                    events.push({
                        title: $(this).attr('title'),  
                        start: $(this).attr('start'), 
                        end: $(this).attr('end'),
                        id: $(this).attr('id'),
                        description: $(this).attr('description')
                    });

                });
                callback(events);
                } ,                                                                   
            error: function () {
                alert("There was an error fetching events!")
            }
        });
    },
    eventRender: function (event, element) {
        element.find('.fc-title').append("<br/>" + event.description);
    },
    //this is the problem...how to set the eventOrder?
    eventOrder: ["description"]
    }

【问题讨论】:

    标签: jquery events fullcalendar


    【解决方案1】:

    首先你需要确保你使用的是FullCalendar v.2.4

    然后,您需要删除“描述”周围的括号“[]”。

    eventOrder: "description"
    

    检查这个小提琴,我按标题降序排序:http://jsfiddle.net/slyvain/waa23ry0/

    【讨论】:

    • 我使用的是 V 2.4。小提琴页面返回 404 错误。但我会尝试你的建议。
    • 还是不行。我更改了描述的名称,因此订单应该更改并且不受影响。我也尝试使用“标题”进行排序,它不会改变事件顺序
    • 我为链接道歉,我打开了几个 JS,我复制粘贴了错误的一个。这是:jsfiddle.net/slyvain/waa23ry0
    • 那行得通。也许 eventOrder 需要在我定义事件之前。让我试试看。
    • 那行不通。但我的活动超过 1 天。它们有 7 天之久。它们不会在同一天开始和停止。这是个问题吗?
    猜你喜欢
    • 1970-01-01
    • 2010-12-18
    • 1970-01-01
    • 2019-02-07
    • 2014-10-10
    • 1970-01-01
    • 2012-06-12
    • 1970-01-01
    相关资源
    最近更新 更多