I am implementing this jquery plugin in my project: link
As you will see in the script, I am calling certain functions under the sixth line, and just below those if, I am changing the background-color of the div that displayed the contextMenu. The problem is that this action applies only if I clicked on one of the options in the contextMenu and not when I click outside of the contextMenu, which I need.
the script:
$(function() { // Context menú, lo del click derecho
$.contextMenu({
selector: '.context-menu-one',
trigger: 'hover',
delay: 500,
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';
}}
}
});
$('.context-menu-one').on('click', function(e){
console.log('clicked', this);
})
});