我制作了这个问题的http://jsfiddle.net/german_martin/oprkvys1/示例。
我有一个带有ContextMenu的大div(蓝色的)和另一个带有另一个contextmenu的div(绿色的)。两个contextmenu都会右键单击显示。
如果我在蓝色div中做出正确的clic,则ContextMenu显示正常。但是,当我在绿色div中clic仍然出现旧的contextmenu。如果我刷新页面并且只是绿色div中的clic,它会显示正确的contextMenu。
这是我的HTML:
<div class="CuadroFondo">
<div class="SingleItem">ITEM 1</div>
<div class="SingleItem">ITEM 2</div>
<div class="SingleItem">ITEM 3</div>
</div>
这是我的js代码:
//Centralizacion del dialog modal en la pantalla
$(document).ready(function () {
$.contextMenu({
selector: '.CuadroFondo',
events: {
//Funcion para cambiarle el titulo a la opcion Seguridad en el menu flotante
show: function () {
var id = $(this).attr('id');
},
},
callback: function (key, options) {
if (key == "expand") {
alert("expand");
}
//se borra un desarrollador
if (key == "creargrupo") {
alert("creargrupo");
}
//Se edita la Seguridad del globo
if (key == "seguridadgrupo") {
alert("jejeje")
}
},
items: {
"expand": { name: "Irak", icon: "add-expand" },
"sep1": "--MAIN MENU--",
"creargrupo": { name: "Afganistan", icon: "crearnuevo" },
}
});
$.contextMenu({
selector: '.SingleItem',
events: {
//Funcion para cambiarle el titulo a la opcion Seguridad en el menu flotante
show: function () {
var id = $(this).attr('id');
},
},
callback: function (key, options) {
if (key == "expand") {
alert("expand");
}
//se borra un desarrollador
if (key == "creargrupo") {
alert("creargrupo");
}
//Se edita la Seguridad del globo
if (key == "seguridadgrupo") {
alert("jejeje")
}
},
items: {
"expand": { name: "Miami", icon: "add-expand" },
"sep1": "--SUBMENU--",
"seguridadgrupo": { name: "Florida", icon: "seguridad" }
}
});
})