新手遇到的问题:Easy UI的对话框老是在页面载入完毕后自己主动弹出

因为是第一次接触Easy UI,还不是非常熟悉,尝试了一下对话框功能,还是非常不错的。但问题是页面载入完毕后。全部的对话框都自己主动弹出来了,百度了好久,也没有详细说明确的,貌似别人都没有这个问题哦


下面是Easy UI 官方提供的演示样例(页面载入完毕后对话框自己主动弹出)


<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Basic Dialog - jQuery EasyUI Demo</title>
    <link rel="stylesheet" type="text/css" href="./jquery-easyui-1.4/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="./jquery-easyui-1.4/themes/icon.css">
 
    <script type="text/javascript" src="./jquery-easyui-1.4/jquery.min.js"></script>
    <script type="text/javascript" src="./jquery-easyui-1.4/jquery.easyui.min.js"></script>
</head>
<body>
    <h2>Basic Dialog</h2>
    <p>Click below button to open or close dialog.</p>
    <div style="margin:20px 0;">
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#dlg').dialog('open')">Open</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#dlg').dialog('close')">Close</a>
    </div>
    <div id="dlg" class="easyui-dialog" title="Basic Dialog" data-options="iconCls:'icon-save'" style="400px;height:200px;padding:10px">
        The dialog content.
    </div>
</body>
</html>

下面是Easy UI 官方文档介绍的Dialog的属性(但当中并没有关于状态的信息)



但在该演示样例中却加入一个closed属性


于是我在自己的演示样例代码中也增加了该属性

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Basic Dialog - jQuery EasyUI Demo</title>
    <link rel="stylesheet" type="text/css" href="./jquery-easyui-1.4/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="./jquery-easyui-1.4/themes/icon.css">
 
    <script type="text/javascript" src="./jquery-easyui-1.4/jquery.min.js"></script>
    <script type="text/javascript" src="./jquery-easyui-1.4/jquery.easyui.min.js"></script>
</head>
<body>
    <h2>Basic Dialog</h2>
    <p>Click below button to open or close dialog.</p>
    <div style="margin:20px 0;">
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#dlg').dialog('open')">Open</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#dlg').dialog('close')">Close</a>
    </div>
    <div id="dlg" class="easyui-dialog" title="Basic Dialog" data-options="iconCls:'icon-save',closed:true" style="400px;height:200px;padding:10px">
        The dialog content.
    </div>
</body>
</html>

果然攻克了刚才遇到的问题,后来才发现。原来closed属性是在window中定义的。而dialog是window的一种扩展,自然也包括这个属性。

The properties extend from window, below is the overridden properties for dialog.



原文地址:https://www.cnblogs.com/cynchanpin/p/6751545.html