jquery dialog fire open event twice -
i have problem jquery-ui.
i bind click event open dialog, dialog's open function fires twice.
the click event fires once, open function opens 2 dialog
this code:
<div id="modalwindow">cargando...</div> <script> $(document).ready(function () { var ventana = $("div#modalwindow"); ventana.dialog({ autoopen: false, show: "slow", hide: "slow", width: 500, resizable: false, draggable: false, modal: true, closeonescape: true, ok: function () { $(this).dialog("close").html("cargando..."); }, close: function () { $(this).html("cargando..."); } }); $("div.imagen_perfil img").click(function (evt) { //...some code ventana.dialog({ title: "subir imagen", open: function (event, ui) { //...loads partialview } }); ventana.dialog("open"); }); }); </script>
this html fires click event:
<li> <label >imagen de perfil:(click en la imagen para agregar):</label> <div class="imagen_perfil"> <img src="~/images/imagen_pordefecto.png"/> </div> </li>
it's because calling dialog
function again in click (which triggers first open
call, second actual call open
), if can ommit dialog function, solves problem, if have change information dialog, should use option
method (instead of calling dialog
again)
ventana.dialog( "option", { title: 'new title',open:function(){...} } );
Comments
Post a Comment