问题
I want to open a dialog box for confirmation on click of a button. For that I am using the following code
$('#dialog-box').dialog({
                show : 'drop',
....
where #dialog-box is an ID for button. Now I am getting an error: Uncaught TypeError: Object [object Object] has no method 'dialog'
Which js File need to be included so that this error is removed
回答1:
The .dialog() function is part of JQuery UI.
Here's a library from Google's CDN.
To make sure that you get everything that you need for JQuery UI, you can download it from here
or use their online hosted scripts from here.
Here's a sample script
Note the order in which I retrieve the libraries and then execute the script:
- JQuery
- JQuery UI
- Initialize dialog box
<!-- JQuery UI stylesheet --> 
<link rel="stylesheet" href="http://code.jquery.com/ui/1.8.18/themes/base/jquery-ui.css" type="text/css" media="all" />
<!-- First get JQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<!-- Then get JQuery UI -->
<script src="http://code.jquery.com/ui/1.8.18/jquery-ui.min.js"></script>
<script>
    $(function() {
        $( "#dialog-box" ).dialog({
            width: "auto",
            height: "auto"
        });
    });
</script>
<div id="dialog-box" title="Getting down with dialog boxes">
    <p>This is how you initialize and use the dialog box.</p>
</div>
来源:https://stackoverflow.com/questions/10024775/which-js-file-to-be-included-to-use-the-function-of-dialog