Different context menu in same page

Different context menu in same page

gorkagorka Posts: 5Questions: 2Answers: 0

Hi,

I have a page with two different tables and each of then has his ouwn context menu.
Each table has his own id, tablaImportarLiquidaciones and tablaLiquidaciones.

When I do click in tablaLiquidaciones rows no context menu is shown and when I do click in tablaImportarLiquidaciones rows the context menu defined for the table tablaLiquidaciones is shown. What is my mistake?

This is my code:

$(document).ready(function() {

     //context menu for tablaImportarLiquidaciones
    $(document).contextmenu({
        delegate: "#tablaImportarLiquidaciones tbody tr",
        autoFocus: true,
        preventContextMenuForPopup: true,
        preventSelect: true,
        taphold: true,
        beforeOpen: function(event, ui) {

        },
        menu: [{ // Opciones disponibles en el menu contextual
                title: "Importar",
                    cmd: "importar",
                    uiIcon: "far fa-download fa-lg text-primary float-left mr-3                 }   
            }
        ],

        select: function(event, ui) {
            var numexp = ui.extraData.numExp;
            var numLiq = ui.extraData.numLiq;
            switch (ui.cmd) { // Acciones asociadas a cada opción del menú
                case "importar":
                    break;
            }
        }
    });

       //context menu for tablaLiquidaciones 
    $(document).contextmenu({
        delegate: "#tablaLiquidaciones tbody tr",
        autoFocus: true,
        preventContextMenuForPopup: true,
        preventSelect: true,
        taphold: true,
        beforeOpen: function(event, ui) {
                        },
        menu: [{ // Opciones disponibles en el menu contextual
                title: "Fase tramitación",
                    cmd: "tramitacion",
                    uiIcon: "far fa-pencil fa-lg text-primary float-left mr-3"  
            },
            {
                title: "Fase resolución",
                cmd: "resolucion",
                uiIcon: "far fa-pencil fa-lg text-primary float-left mr-3"  
            },
            {
                title: "Eliminar",
                cmd: "delete",
                uiIcon: "far fa-trash-alt fa-lg text-danger float-left mr-3",
            }
        ],

        select: function(event, ui) {
            var numexp = ui.extraData.numExp;
            var numLiq = ui.extraData.numLiq;
            switch (ui.cmd) { // Acciones asociadas a cada opción del menú
                case "tramitacion":
                    break;
                    case "resolucion":
                    break;
                    case "delete":
                    break;
            }
        }
    });

});

Thanks for your help.

This discussion has been closed.