【发布时间】:2009-08-08 15:56:27
【问题描述】:
如果提交时出现一个或多个错误,我有一个生成以下标记的表单:
<ul class="memError">
<li>Error 1.</li>
<li>Error 2.</li>
</ul>
我想将此元素设置为提交后出现的模态窗口,单击即可关闭。我有 jquery,但找不到触发模式窗口的正确事件。这是我正在使用的脚本,改编自an example I found here:
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
$('.memError').load(function() {
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set heigth and width to mask to fill up the whole screen
$('#mask').css({
'width': maskWidth,
'height': maskHeight
});
//transition effect
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow", 0.8);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH / 2 - $(id).height() / 2);
$(id).css('left', winW / 2 - $(id).width() / 2);
//transition effect
$(id).fadeIn(2000);
});
//if close button is clicked
$('.memError').click(function(e) {
$('#mask').hide();
$('.memError').hide();
});
});
//]]>
</script>
我已经为#mask 和.memError 设置了与example 几乎相同的样式,但是当我加载ul.memError 时,我什么也看不到。我尝试过其他 events 试图蒙混过关,但我还没有掌握所需的 javascript。
谁能指出我正确的方向?
【问题讨论】:
-
您希望在提交后发生这种情况(等文档准备好)还是 ajax 提交?
-
一个ul顺便没有load事件
-
> 您希望在提交之后发生这种情况(等文档准备好)还是 ajax 提交?这是一个非 ajax 提交,所以文档准备好了。本质上,如果指定的 ul 存在,我只需要这样做。
标签: javascript jquery modal-dialog