I have a problem with jquery-ui.
我有一个jquery-ui的问题。
I bind a click event to open a dialog, but the dialog's open function fires twice.
我绑定一个click事件来打开一个对话框,但是对话框的open函数会触发两次。
The click event only fires once, is only the open function that opens two dialog
click事件只触发一次,只是打开两个对话框的open函数
This is my 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 is the HTML that fires the click event:
这是触发click事件的HTML:
<li>
<label >Imagen de perfil:(Click en la Imagen Para Agregar):</label>
<div class="imagen_perfil">
<img src="~/images/imagen_pordefecto.png"/>
</div>
</li>
1 个解决方案
#1
3
It's because you are calling the dialog
function again in the click (which triggers the first open
call, the second is your actual call to open
), If you can ommit the dialog function, that solves the problem, if you really have to change information about the dialog, you should use the option
method (instead of calling dialog
again)
这是因为你在点击中再次调用对话框功能(触发第一个opencall,第二个是你打开的实际调用),如果你可以省略对话功能,那就解决了问题,如果你真的需要改变有关的信息对话框,你应该使用选项方法(而不是调用dialogagain)
ventana.dialog( "option", { title: 'New Title',open:function(){...} } );
#1
3
It's because you are calling the dialog
function again in the click (which triggers the first open
call, the second is your actual call to open
), If you can ommit the dialog function, that solves the problem, if you really have to change information about the dialog, you should use the option
method (instead of calling dialog
again)
这是因为你在点击中再次调用对话框功能(触发第一个opencall,第二个是你打开的实际调用),如果你可以省略对话功能,那就解决了问题,如果你真的需要改变有关的信息对话框,你应该使用选项方法(而不是调用dialogagain)
ventana.dialog( "option", { title: 'New Title',open:function(){...} } );