Hi, I'm doing a web with jquery and c #.
The problem I have is that when I click on menus on the web more than once, I think the html content of the page is being loaded again and again. With this, clicking on the menu repeats the click () event and clicks 2 times.
I would like to know how I can delete the previous script when loading the same html page again so that it does not end the page with the same script many times. Thanks.
The complete code is the following: Top Menu
$(function () {
$("[id*='gestion_polizas']").click(function () {
$("[id*='leftWrapper']").hide();
$("[id*='contenido']").load("Polizas/gridPolizas.aspx");
//$("[id*='leftWrapper']").load("Recibos/menuLateral_recibos.aspx");
//por si tarda al cargar cuando se pulsa el boton
//$("[id*='contenido']").load("Cargando.aspx");
//setTimeout($("[id*='contenido']").load("JqGridInformatica.aspx"), 2000);
});
})
When clicking on a row in the grid (opens the side menu)
onSelectRow: function (row_id) {
//hago un hide en el formulario anterior para crear el efecto
//de cargar e la izquiera de nuevo
$("#div_formularioPolizas").hide();
//llamo a la funcion que le da datos al formulario a partir del key del jqgrid
rellenar_formulario(row_id);
//cargo el menu lateral
$("[id*='leftWrapperPolizas']").load("Polizas/menuLateral_polizas.aspx");
//muestor el menu lateral con efecto
$("[id*='leftWrapperPolizas']").show(1000);
Side menu that opens when you click on a grid row
<body>
<div id="menuPolizass">
<div id="listView" class="list listView">
<li class="<%--list-item-active--%>"><a href="#" id="menuLateral_cliente" class='target listView'>Cliente</a></li>
<li><a href="#" id="menuLateralPolizas_recibos" class='target listView'>Recibos</a></li>
<li><a href="#" id="menuLateralPolizas_siniestros" class='target listView'>Siniestros</a></li>
<li><a href="#" id="menuLateralPolizas_tarificacion" class='target listView'>Tarificación</a></li>
<li><a href="#" id="menuLateralPolizas_imprimir" class='target listView'>Imprimir</a></li>
</div>
<div id="flotantePolizas"></div>
function funciones_MenuLateral() {
$("#menuLateralPolizas_recibos").unbind("click");
$("#menuLateralPolizas_recibos").click( function () {
if ($("#jqGridRecibos").length == 0) {
$("[id*='flotantePolizas']").load("Recibos/gridRecibos.aspx");
$("[id*='flotantePolizas']").dialog({
width: 1200,
height: 800,
beforeClose: function (event, ui) {
//al cerrar el dialog borro el jqgrid para que no haya error al volverlo a abrir
alert("cerrado");
$("#jqGridRecibos").remove();
}
}).dialogExtend({
"closable": true,
"maximizable": false,
"minimizable": true,
"collapsable": true,
});
//return false;
$("[id*='menuLateralPolizas_recibos']").attr('id', 'NEWID');
}
else {
alert("Esta ventana ya esta abierta");
}
});
}
funciones_MenuLateral();