I am using jquery-2.1.0.min.js and jquery.ui-1.10.4.
Here is my full source code:
(For the jquery-ui.css link tag, change: href="path_to_your_jquery-ui/themes/base/jquery-ui.css")
(For the jquery script tag, change: src="path_to_your_jquery/jquery-2.1.0.min.js")
(For the jquery-ui script tag, change: src="path_to_your_jquery-ui/ui/jquery-ui.js")
(For your demos.css link tag, change: href="path_to_your_jquery-ui/demos/demos.css")
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="add-ons/jui/themes/base/jquery-ui.css"/>
<script src="add-ons/jquery-2.1.0.min.js"></script>
<script src="add-ons/jui/ui/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="add-ons/jui/demos/demos.css"/>
<!-- this in-file styling is used to hide the #dialog element initially -->
<style>
#dialog {
display: none;
}
</style>
<script>
$(document).ready(function() {
$("#put").on("click", function(evnt) {
$(function() {
$("#dialog").dialog({
width:250,
height: 180,
modal:true
});
});
evnt.preventDefault();
});
});
</script>
</head>
<body>
<div id="dialog" title="Basic dialog">
<p>
This is the default dialog which is useful for displaying information.
The dialog window can be moved, resized and closed with the 'x' icon.
</p>
</div>
<div>
<button type="button" id="put">Insert data</button>
</div>
</body>
</html>
Be sure to pass an event parameter to your callback function in your 'on click' function and call the preventDefault() method on it. Read more about event.preventDefault() Also, here's an good read on event.preventDefault() vs. return false