easyui 窗口的onBeforeClose 使用
2015-08-12 11:24
281 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <link href="/jquery-easyui-1.3.2/themes/icon.css" rel="stylesheet" type="text/css" /> <link href="/jquery-easyui-1.3.2/themes/default/easyui.css" rel="stylesheet" type="text/css" /> <script src="/jquery-easyui-1.3.2/jquery-1.8.0.min.js" type="text/javascript"></script> <script src="/jquery-easyui-1.3.2/jquery.easyui.min.js" type="text/javascript"></script> <script src="/jquery-easyui-1.3.2/locale/easyui-lang-zh_CN.js" type="text/javascript"></script> <script type="text/javascript"> var bSave = false; var bClose = true; $(function () { $("#btnOpen").click(function () { bSave = false; //模拟标记数据是否保存,如果没保存,询问是否退出 bClose = false; $("#myDialog").dialog({ title: "测试对话框", width: 600, height: 300, modal: true, onBeforeClose: function () { if (!bSave && !bClose) { $.messager.confirm("提醒", "信息尚未保存,是否退出?", function (r) { if (r) { bClose = true;//标记可以退出 $("#myDialog").dialog("close"); } }); } return bClose; //通过全局变量来控制是否关闭窗口 }, buttons: [{ text: "确定", iconCls: 'icon-ok', handler: function () { bSave = true; bClose = true; $("#myDialog").dialog("close"); } }, { text: "取消", iconCls: "icon-tools", handler: function () { $("#myDialog").dialog("close"); } }] }); }); }); </script> </head> <body> <div id="myLayout" class="easyui-layout" data-options="fit:true"> <div data-options="region:'center'"> <div id="myTabs" class="easyui-tabs" data-options="fit:true"> <div title="Tab1" style="padding: 20px;"> <input type="button" id="btnOpen" value="单击我打开窗口" /> </div> </div> </div> </div> <div id="myDialog" title="My Dialog"> <div class="easyui-layout" data-options="fit:true"> <div data-options="region:'center'"> </div> </div> </div> </body> </html>
相关文章推荐
- 【Mui】后台框架之表格控件
- UVa 10190 - Divide, But Not Quite Conquer!
- UVa 12167 & HDU 2767 强连通分量 Proving Equivalences
- 使用 spice-guest-tools 让虚拟机支持spicec 双屏显示
- iOS中的NSValue
- KMP算法的next、next value数组代码实现及POJ3461
- iOS UICollectionView实现瀑布流(3)
- LeetCode题解:Implement Stack using Queues
- UE4 Editor View Modes
- 更新sdk后遇到This Android SDK requires Android Developer Toolkit version 20.0.0 or above
- iOS基础-UIKit框架-高级视图-UIDatePicker
- WM_CLOSE WM_QUIT WM_DESTROY 三者的区别
- Bit Manipulation - Repeated DNA Sequences
- ios开发之实现长按UITableViewCell弹出UIMenuController
- LeetCode:Implement Queue using Stacks
- xquery 除法 和节点个数
- 自己封装的Metro风格的后台UI框架,暂命名MUI(持续更新)
- iOS UITextView内容添加后,自动滚动到最后一行
- UICollectionView入门--使用系统UICollectionViewFlowLayout布局类
- LeetCode题解:Implement Queue using Stacks