JQuery UI Dialog usage (1/2)

Source: Internet
Author: User
Tags prepare

The client's dialog box was used to learn the dialog box in the jquery UI.

Preparing for the jquery environment
First, we create a button, and when we click on the button, a dialog box pops up.

1 <input type= "button" value= "delete" id= "btn"/>


In order to set this button to click on the event, you need to prepare the jquery environment.

1 <script type= "text/web Effects" src= "Scripts/jquery-1.4.2.js" ></script>

Set the Click event for the button in ready.

1 $ (function () {
2//initialization
3 $ ("#btn"). Click (function () {
4 Alert ("BTN" was clicked!) ");
5}
6);


Confirm that this step is not a problem.

Prepare dialog box
In the second step, you need to prepare the contents of the dialog box. This content comes from the demo file of the jquery UI.

1 <div id= "dialog-confirm" title= "Empty the Recycle Bin?" >
2 <p>
3 <span class= "Ui-icon ui-icon-alert" style= "Float:left"; margin:0 7px 20px 0; " ></span>
4 these items would be permanently deleted and cannot to be recovered. Are you sure?</p>
5 </div>

In order to use the JQuery UI dialog box, you need to add references to these files.

1 <script type= "Text/javascript" src= "Scripts/jquery.ui.core.js" ></script>
2 <script type= "Text/javascript" src= "Scripts/jquery.ui.widget.js" ></script>
3 <script type= "Text/javascript" src= "Scripts/jquery.ui.mouse.js" ></script>
4 <script type= "Text/javascript" src= "Scripts/jquery.ui.button.js" ></script>
5 <script type= "Text/javascript" src= "Scripts/jquery.ui.draggable.js" ></script>
6 <script type= "Text/javascript" src= "Scripts/jquery.ui.position.js" ></script>
7 <script type= "Text/javascript" src= "Scripts/jquery.ui.dialog.js" ></script>

Add Style

The jquery UI uses a number of styles to decorate, and needs to refer to the jquery UI style, note that the Jquery.ui.all.css tutorial this file refers to a large number of other style files, bringing the jquery UI The contents of the Development-bundlethemesbase folder are copied over.

1 <link type= "text/css" href= "Styles/jquery.ui.all.css" rel= "stylesheet"/>
In the Ready function, this dialog box is also initialized.

1 $ (function () {
2//initialization
3 $ ("#btn"). Click (function () {
4 Alert ("BTN" was clicked!) ");
5});
6
7//Initialization dialog box
8 $ ("#dialog-confirm"). Dialog ();
9});


Now, when you open this page, you can already see the dialog box.

Home 1 2 last page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.