E
I found the solution in the documentation and it's pretty simple:
https://swisnl.github.io/jQuery-contextMenu/docs.html#events The code is as follows:$(function() { // Context menú, lo del click derecho
$.contextMenu({
selector: '.context-menu-one',
trigger: 'hover',
delay: 500,
autoHide: true,
callback: function(key, options) {
if(key=="Editar") Editar_hora($(this).text());
if(key=="Eliminar") Eliminar_hora($(this).text());
if(key=="Nueva fila") Nueva_fila($(this).text());
if(key=="Nuevo Horario") Nuevo_horario($(this).text());
$(this).css("background-color","#5589DC");
},
items: {
"Editar": {name: "Editar hora del turno", icon: "edit"},
"Nueva fila": {name: "Nueva fila", icon: "add"},
"Nuevo horario": {name: "Nuevo turno", icon: "add"},
"Eliminar": {name: "Eliminar este turno", icon: "delete"},
"sep1": "---------",
"quit": {name: "Cerrar", icon: function(){
return 'context-menu-icon context-menu-icon-quit';
}}
},
events: {
hide : function(options){
$(this).css("background-color","#5589DC");
}}
});
$('.context-menu-one').on('click', function(e){
console.log('clicked', this);
})
});
He had searched for a lot and did not give in the nail for knowing little English ≤.EDIT:The missing piece of code was this, which is not included in the plugin, but found it in its documentation:,
events: {
hide : function(options){
$(this).css("background-color","#5589DC");
}}
It basically throws an event when the ContextMenu is hidden, it is appreciated that I am changing the background-color, but this time it will do so when you click outside the ContextMenu.