1

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

Joan Paz
  • 25
  • 5
  • I don't know your context menu plugin, but perhaps it should be: `$(element).contextmenu({ menu: [{` etc? Then it applies the context menu directly to the current event element. – ADyson Sep 06 '17 at 08:38
  • Nope, i've tried with element call to jquery, but it doesn't work – Joan Paz Sep 08 '17 at 02:37
  • so it gives you the exact same issue, or something else? It would help if you tell us what this contextMenu plugin is from, then we can study the docs for it – ADyson Sep 08 '17 at 05:45
  • Nope. ContextMenu is only invocable when i have the `$('#calendar2').contextmenu({ menu: [{` etc, other sentence will not work. My detail is when i've got 2 events or more in a day and i must apply a function within the contextmenu, only works for the last event – Joan Paz Sep 08 '17 at 11:34
  • What does "will not work" mean, exactly? You get an error in the console? Or just nothing? Again, it would help if you tell us what this contextMenu plugin is from, then we can study the docs for it. – ADyson Sep 08 '17 at 12:58
  • just nothing when i make the call with `$(element).contextmenu` – Joan Paz Sep 08 '17 at 23:42
  • ok. So one more time, can you please tell me what your contextmenu plugin is? Where is the code? Where is the documentation? If you give the URL for it then I can actually look and see how it's meant to be used and how that might be made to work with fullCalendar. Without that I'm just guessing. – ADyson Sep 10 '17 at 19:20
  • jquery-ui-contextmenu.js, source code is here: [jquery-ui-contextmenu](https://github.com/mar10/jquery-ui-contextmenu) – Joan Paz Sep 11 '17 at 15:13

0 Answers0