Javascript FullCalendar-通过模式删除事件

Javascript FullCalendar-通过模式删除事件,javascript,jquery,twitter-bootstrap,fullcalendar,Javascript,Jquery,Twitter Bootstrap,Fullcalendar,我正在使用FullCalendar,但我一直在尝试删除事件。 交易如下: 当我点击一个事件时,它会给我带来一个模式,其中包含关于该事件的所有信息,在这个模式中,我有两个按钮:一个接受事件,一个拒绝事件。 我需要的是,当我点击“接受”时,活动颜色必须变为绿色,当我拒绝活动时,必须将其删除。 我该怎么做? 这是我的密码: CalendarioAgenda.html(在模态所在的位置,我简化了代码以便更容易理解,但我的每个字段都像#modalclient): 谢谢你的行$('#ModalId').ht

我正在使用FullCalendar,但我一直在尝试删除事件。 交易如下: 当我点击一个事件时,它会给我带来一个模式,其中包含关于该事件的所有信息,在这个模式中,我有两个按钮:一个接受事件,一个拒绝事件。 我需要的是,当我点击“接受”时,活动颜色必须变为绿色,当我拒绝活动时,必须将其删除。 我该怎么做? 这是我的密码:

CalendarioAgenda.html(在模态所在的位置,我简化了代码以便更容易理解,但我的每个字段都像#modalclient):

谢谢你的行
$('#ModalId').html(event.id)
var id=$('#ModalId').val()的目标是两个不同的元素,因此无法检索调用
val()
的事件id

通过设置值,如so
$('#ModalId').val(event.id)工作正常

以下是您可以移除事件并更改背景颜色的部分:

$('.Recusar').click(function (events) {
   var id = $('#ModalId').val();
   $('#calendar').fullCalendar('removeEvents', id);
   $("#calendar").fullCalendar('addEventSource', events);
   $('#ModalVistoria').modal('hide');
});

$('.Aceitar').click(function (events) {
  var id = $('#ModalId').val();
  var ev = $("#calendar").fullCalendar('clientEvents', id);
  ev[0].backgroundColor = 'green';
  $("#calendar").fullCalendar('addEventSource', events);
  $('#ModalVistoria').modal('hide');
});
下面是一个正在工作的JSFIDLE:

$('#calendar').fullCalendar({ //re-initialize the calendar
            header: h,
            defaultView: 'month', // change default view with available options from http://arshaw.com/fullcalendar/docs/views/Available_Views/ 
            slotMinutes: 15,
            editable: true,
            droppable: false, // this allows things to be dropped onto the calendar !!!
            events: [{
                id: '01',
                title: 'Vistoria Viceri',
                start: new Date(y, m, 1), //usar start no campo de data da modal
                backgroundColor: Metronic.getBrandColor('yellow'),
                cliente: 'Viceri',
                tipo: 'Empresarial Simples',
                hora: '12:00',
                endereco: 'General Osorio, 61',
                bairro: 'Centro',
                cidade: 'Jundiai',
                estado: 'SP',
                contato: 'Marcel Pratte',
                telefone: '11 3308 6999',
            }, {
                id: '02',
                title: 'Visita a cliente',
                start: new Date(y, m, d - 5),
                end: new Date(y, m, d - 3),
                backgroundColor: Metronic.getBrandColor('green'),
                cliente: 'Maxtel',
                tipo: 'Empresarial',
                hora: '15:00',
                endereco: 'Avenidade Sao Joao',
                bairro: 'Ponte Sao Joao',
                cidade: 'Jundiai',
                estado: 'SP',
                contato: 'Marcio',
                telefone: '11 45270001',
            }, {
                id: '03',
                title: 'Vistoria Envision',
                start: new Date(y, m, d - 3, 16, 0),
                allDay: false,
                backgroundColor: Metronic.getBrandColor('red'),
                cliente: 'Envision',
                tipo: 'Empresarial complexa',
                hora: '12:36',
                endereco: 'Rua da empresa',
                bairro: 'Centro',
                cidade: 'Sao Paulo',
                estado: 'SP',
                contato: 'Joaquim',
                telefone: '011 995257788',
            }],

            //opção de click no evento para redirecionar para modal
            eventClick: function (event, jsEvent, view) {
                $('.modal-title').html(event.title);
                $('#ModalCliente').html(event.cliente);
                $('#ModalTipo').html(event.tipo);
                $('#ModalDataHora').html(event.d + ' - ' + event.hora);
                $('#ModalEndereco').html(event.endereco);
                $('#ModalBairro').html(event.bairro);
                $('#ModalCidade').html(event.cidade);
                $('#ModalEstado').html(event.estado);
                $('#ModalContato').html(event.contato);
                $('#ModalTel').html(event.telefone);
                $('#ModalId').html(event.id);
                $('#ModalVistoria').modal();

                $('.Recusar').click(function (events) {
                    var id = $('#ModalId').val();
                    $('#calendar').fullCalendar('removeEvents', id);
                    $("#calendar").fullCalendar('addEventSource', events);
                });

            }
        });
$('.Recusar').click(function (events) {
   var id = $('#ModalId').val();
   $('#calendar').fullCalendar('removeEvents', id);
   $("#calendar").fullCalendar('addEventSource', events);
   $('#ModalVistoria').modal('hide');
});

$('.Aceitar').click(function (events) {
  var id = $('#ModalId').val();
  var ev = $("#calendar").fullCalendar('clientEvents', id);
  ev[0].backgroundColor = 'green';
  $("#calendar").fullCalendar('addEventSource', events);
  $('#ModalVistoria').modal('hide');
});