使用 JQuery UI 对话框从确认对话框返回值 [英] Returning value from confirmation dialog using JQuery UI dialog
问题描述
我正在使用 jQuery UI 对话框 在单击按钮时显示确认对话框.我想返回 true
,当点击 OK 时返回 false
否则.
在 onClick
中关联对话框打开调用(如给定 here, $dialog.dialog('open');
) 事件不能达到目的.因此,作为一种解决方法,我采用了一种类似于此的方法:http://www.perfectline.co.uk/blog/unobtrusive-custom-confirmation-dialogs-with-jquery.这种方法和我的方法有两个区别:
- 该示例使用锚标记和,
- 它不使用 jQuery UI 对话框.
我已经修改了示例链接中给出的代码,但它不起作用.我想知道我做错了什么.有没有更便宜的方法来做到这一点?
这是代码,所有的 CSS/JS 都引用了 jQuery CDN,所以你应该能够复制代码来查看行为.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><头><link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/blitzer/jquery-ui.css" rel="stylesheet"/><script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js"></script><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>控制面板</title>头部><身体><form action="http://google.com"><button class="es-button ui-state-default ui-corner-all" name="changeSem" id="id2">开始热核战争</span>按钮></表单><div title="为什么这么认真?"id="id3" style="display:none;"><p>你要发动战争了.<p>单击确定"进行确认.单击取消以取消此操作.</p>