使用完整日历保存SQL,同时在日历上删除外部事件

时间:2016-03-09 15:15:21

标签: c# jquery fullcalendar

我想在SQL上保存一个事件,而我在日历上删除一个外部事件

$('#calendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaDay'
    },
    editable: true,
    droppable: true, 
    revert: true,
    drop: function (resourceId) {
        $(this).remove();
    /*here I want to save the external event getting the Id event*/
    },
    eventDrop: function (event, delta, revertFunc) {
    /*and here I want to update the event when I drag and drop the envent on the calendar*/
    }

});

我有功能吗?或者" drop"我可以保存活动吗?

1 个答案:

答案 0 :(得分:0)

我明白了!

//declare 2 global var

var IDEVENT;
var DATE;

$("#calendar").fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month'
    },
    lang: 'es',
    editable: true,
    droppable: true,
    revert: true,
    drop: function (date, allDay, ev, ui) {

        var title = $(this).text(); //here I get the event name
        var id = $('#txt' + title).val(); // and here get the event id

        IDEVENT = id;  //here on the global var, assigned the event id

        var fech = (new Date(date)).toISOString().slice(0, 10); //with this line get the date of calendar with this format  0000-00-00
        DATE= fech; //here on global var, assigned the date 

        saveAgenda(); //here reference the method to save the event, when I drop the event

    }
});

//the saveAgenda function


function saveAgenda(){

var idFixedAsset= IDEVENT; //On global var, I get the idEvent
var date= DATE; //On global var, I get the date with format 0000-00-00
var idUser = $('#lblIdUser').html();

 block();
    $.ajax({
        url: "Agenda.aspx/saveAgenda",
        data: "{idFixedAsset:" + idFixedAsset + ",date:'" + date + "', idUser:" + idUser + "}",
        dataType: "json",
        type: "post",
        contentType: "application/json; charset=utf-8",
        success: function (data) {
           unBlock();
           alert('Success');
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            unBlock();
            alert("Error");
        }
    });