Add close button to dialog
Description
The following code shows how to add close button to dialog.
Example
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){<!-- ww w .j a v a 2 s. c o m-->
Dialog_header.onclick = function(e) {
$("#Dialog").fadeOut(500);
};
Button1.onclick = function(e) {
var $dialog = $("#Dialog");
if (!$dialog.hasClass('ui-dialog')) {
$dialog.page();
}
$dialog.fadeIn(500);
};
Button2.onclick = function() {
$("#Dialog").fadeOut(500);
};
}
</script>
<link rel="stylesheet"
href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script
src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>
</head>
<body>
<div data-role="page" id='Page1'>
<div data-role='button' id="Button1">Open Dialog</div>
</div>
<div data-role="dialog" id='Dialog'>
<div data-role='header' id='Dialog_header'>
<h1>Dialog</h1>
</div>
<div data-role='button' id="Button2">Close</div>
</div>
</body>
</html>