apply functions for contextMenu on each event in FullCalendar.js

313 views Asked by At

I'm working with Fullcalendar.js and I set for each event a Simple Contextmenu that makes a specified function (change status when confirming a medical appointment). Next code sample works fine only when i have an Event in a day (eventRender):

eventRender: function(event, element) {


        var originalClass   = element[0].className;
        element[0].className = originalClass + ' hasmenu';

        $('#calendar2').contextmenu({
                delegate: '.hasmenu',
                menu: [{
                  title: 'Cambiar Estado',
                  cmd: 'cestado',
                  action: function(ui){ui.cmd = "cestado";confirmarCambioEstado(event);}
                }, {
                  title: 'Atender Cita',
                  cmd: 'acita',
                  action: function(ui){ui.cmd = "acita";if(event.color=="#0088cc"){
                actualizarEstado(3,event.id);
                event.color = "yellowgreen";
                calendarJ.fullCalendar('rerenderEvents');
                hrefHCE.href = "HCE?idCita="+event.id;
                hrefHCE.click();
            }else{
                advertenciaEstado();
            }}
              },{
                  title: 'Cancelar Cita',
                  cmd: 'ccita',
                  action: function(ui){ui.cmd = "ccita";event.color = "green";
            confirmarCambioEstado(event);}
              }, {
                  title: 'Eliminar Cita',
                  cmd: 'ecita',
                  action: function(ui){ui.cmd = "ecita";confirmarEliminar(event);}
                }],
            beforeOpen: function (event,ui) {      
                ui.menu.zIndex($(event.target).zIndex() + 1);
            } 
        });   
    },

    eventDrop: function(event, delta, revertFunc){
        confirmarCambioFecha(event,revertFunc);
    },
    eventAfterAllRender: cambiarFuncion
});

But,only works like i want for a day. When i have two or more eventes on a same day, when in apply the functions in the contextMenu, it only makes the function with the last event of the day (if i have 3 events, the functions apply for the last event, not for the specified event i want to apply the functions)

How do i apply the same tratment for each event witouth having that issue i'm showing? i've tried to put a forEach sentence, but i don't know what i do

0

There are 0 answers