完整日历 - 当事件被删除时,如何找到它被删除的 DIV?

发布于 2024-11-27 09:39:13 字数 1727 浏览 3 评论 0原文

我正在开发一个 FullCalendar 实现,它可以完成所有基础功能,并且运行良好(拖放、调整大小、添加、删除、编辑事件)。不过,我最近在我的日历中集成了“重复项目”功能,以纪念周年纪念日等。这也很好。

当我有一个项目(重复,假设 100 次)被拖到新位置时,问题就出现了。进行 ajax 调用来更新数据库中项目以及所有“重复”项目的日期/时间。这可能需要几秒钟 - 所以我想在事件被拖放到的日期 DIV 中显示一个“正在加载”GIF。如何获取 DIV id 或 DIV 作为对象?

编辑

如果有解决办法的话,我也愿意听到日期 div 中加载图形的其他替代方案。

$('#jMonthCalendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },
    editable:true,
    eventSources: [
        "/api/getCalendarItemsAll.php"
    ],

    eventDrop: function ( event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view ){
        updateCalendarItem( event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view, true );
    },
    eventResize: function( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view ){
        updateCalendarItem( event, dayDelta, minuteDelta, null, revertFunc, jsEvent, ui, view, false );
    },

    //... Other Event Handlers

});

function updateCalendarItem( event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view, isDrop ){

    var j=JSON.stringify(event);
    var url = '/api/calendarUpdateItem.php';
    var data = 'j=' + encodeURIComponent(j) + 
              '&dd=' + encodeURIComponent(dayDelta) +
              '&md=' + encodeURIComponent(minuteDelta) +  
              '&dr=' + encodeURIComponent(isDrop) +
              '&ref=' + randomString(30);

    $.getJSON(
        url, data,
        function(result) {
            refreshCalendar();
            if (result.status == "ERR"){
                showError(result.message);
            }
        }
    );          
}

I am working on a FullCalendar implementation that does all of the basics, which are working just fine (Drag/Drop, Resize, Add, Remove, Edit Events). However, I've recently integrated a "repeat item" function into my calendar for anniversaries and such. This is all fine as well.

the problem comes in when I have an item (which is repeated, lets say 100 times) that is dragged to a new location. An ajax call is made to update the dates/times on the item in the database, as well as all of the "repeat" items. This can take a few seconds - so I want to essentially show a "loading" GIF in the date DIV the event was dragged and dropped onto. How does one obtain the DIV id or the DIV as an object?

EDIT

I would also be open to hearing other alternatives to the loading graphic in the date div, if there is a way around it.

$('#jMonthCalendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },
    editable:true,
    eventSources: [
        "/api/getCalendarItemsAll.php"
    ],

    eventDrop: function ( event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view ){
        updateCalendarItem( event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view, true );
    },
    eventResize: function( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view ){
        updateCalendarItem( event, dayDelta, minuteDelta, null, revertFunc, jsEvent, ui, view, false );
    },

    //... Other Event Handlers

});

function updateCalendarItem( event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view, isDrop ){

    var j=JSON.stringify(event);
    var url = '/api/calendarUpdateItem.php';
    var data = 'j=' + encodeURIComponent(j) + 
              '&dd=' + encodeURIComponent(dayDelta) +
              '&md=' + encodeURIComponent(minuteDelta) +  
              '&dr=' + encodeURIComponent(isDrop) +
              '&ref=' + randomString(30);

    $.getJSON(
        url, data,
        function(result) {
            refreshCalendar();
            if (result.status == "ERR"){
                showError(result.message);
            }
        }
    );          
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缘字诀 2024-12-04 09:39:13

我遇到了一些类似的问题,除了页面上有一些选项可以将不同的事件加载到日历中。不幸的是,我不确定如何仅针对事件被删除到的 div 执行此操作,因为各个 div 确实没有定义功能。

我最终做的是使用一个名为 BlockUI 的 jquery 插件在整个日历上创建一个模式,而我在加载新事件时,需要进行一些调整才能使其适合日历,但它传达了信息。这是一个小代码片段。

//this is called when the checkbox is clicked
if(this.value === 'on'){
    $('#mycalendar').fullCalendar( 'addEventSource', '--url--');
    this.disabled = true;
} else {
    $('#mycalendar').fullCalendar( 'removeEventSource', '--url--');
}

下一部分是 fullcalendar 的参数,当某些内容需要卸载或完成加载时调用。

loading: function(bool) {
    if(bool){
        $('#mycalendar').block({
            message: '<h1>Loading...</h1>',
            css: {top: '10% !important'}
        })
    } else {
         $('#mycalendar').unblock();
         $('.processCheck').removeAttr('disabled');
    }
}

我知道这并不完全是您想要的,但我希望它能有所帮助!

I had some what of a similar issue except I had options on the page that would load different events to the calendar. Unfortunately I'm not sure how you could do it just for the div that the event it being dropped to, since there really isn't a defining feature of the individual divs.

What I ended up doing was using a jquery plugin called BlockUI to create a modal over the whole calendar while I was loading new events, it took a little tweaking to get it to fit right over the calendar, but it got the message across. Here's a little code snippet.

//this is called when the checkbox is clicked
if(this.value === 'on'){
    $('#mycalendar').fullCalendar( 'addEventSource', '--url--');
    this.disabled = true;
} else {
    $('#mycalendar').fullCalendar( 'removeEventSource', '--url--');
}

This next part is a parameter of fullcalendar that is called when something needs to unload or completes loading.

loading: function(bool) {
    if(bool){
        $('#mycalendar').block({
            message: '<h1>Loading...</h1>',
            css: {top: '10% !important'}
        })
    } else {
         $('#mycalendar').unblock();
         $('.processCheck').removeAttr('disabled');
    }
}

I know this isn't exactly what you're looking for but I hope it helps anyway!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文