jquery UI Dialog dialog box using learning Notes

Source: Internet
Author: User
Tags explode prepare

The jquery UI is a jquery based open source JavaScript Web user interface code base. A visual control that contains low-level user interaction, animations, effects, and replaceable topics.

Preparing for the JQuery environment

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

The code is as follows Copy Code

<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.

The code is as follows Copy Code

<script type= "Text/javascript" src= "Scripts/jquery-1.4.2.js" ></script>

Set the Click event for the button in ready.

The code is as follows Copy Code

$ (function () {
Class
$ ("#btn"). Click (function () {
Alert ("BTN is clicked!") ");
}
);

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.

The code is as follows Copy Code

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

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

  code is as follows copy code

<script type=" Text/javascript "src=" Scripts/jquery.ui.core.js ">< /script>
 <script type= "Text/javascript" src= "Scripts/jquery.ui.widget.js" ></SCRIPT>
 <script type= "Text/javascript" src= "Scripts/jquery.ui.mouse.js" ></SCRIPT>
 <script Type= "Text/javascript" src= "Scripts/jquery.ui.button.js" ></SCRIPT>
 <script type= "text/" JavaScript "src=" Scripts/jquery.ui.draggable.js "></script>"
 <script type= "Text/javascript" Src= "Scripts/jquery.ui.position.js" ></script>
 <script type= text/javascript "src=" scripts/ Jquery.ui.dialog.js "></script>

Add Style

The jquery UI uses a number of styles to decorate, and you need to refer to the jquery UI style, note that jquery.ui.all.css this file references a large number of other style files, putting the jquery UI The contents of the Development-bundlethemesbase folder are copied over.

The code is as follows Copy Code
1 <link type= "text/css" href= "Styles/jquery.ui.all.css" rel= "stylesheet"/>

In the Ready function, this dialog box is also initialized.

The code is as follows Copy Code


$ (function () {
Class
$ ("#btn"). Click (function () {
Alert ("BTN is clicked!") ");
});

Initialize dialog box
$ ("#dialog-confirm"). Dialog ();
});

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


An example of a combination with asp.net

  code is as follows copy code

<body>
<form id= "Form1" runat= "Server" >
<div id= "Dlg" >
<asp:textbox id= "TextBox1" runat= "Server" ></asp:TextBox>
</div>
<asp:button id= "Showdlg" runat= "server" text= "..."/>
</form>
<script type= "Text/javascript" language= "JavaScript" >
$ (function () {
$ ("#dlg"). Dialog ({
Autoopen:false,
Closed:true,
WIDTH:450,
Modal:true,
Appendto: "Form",
Buttons: {
"OK": function () {
$ ("form"). Submit ();
},
' Cancle ': function () {
$ (This). dialog ("Close");
}
},
Close:function () {
}
});
$ ("#<%=showdlg.clientid%>"). button (). Click (function () {$ ("#dlg"). Dialog ("Open");
}
);
</script>
</body>


Create a simple dialog box:

The code is as follows Copy Code


<script type= "text/javascript>
$.fx.speeds._default = 1000;
$ (function () {
$ ("#dialog"). Dialog ({
Autoopen:false,
Show: "Blind",
Hide: "Explode"
});

$ ("#opener"). Click (function () {
$ ("#dialog"). Dialog ("Open");
return false;
});
});
Script>
<script type= "text/javascript>
$.fx.speeds._default = 1000;
$ (function () {
$ ("#dialog"). Dialog ({
Autoopen:false,
Show: "Blind",
Hide: "Explode"
});

$ ("#opener"). Click (function () {
$ ("#dialog"). Dialog ("Open");
return false;
});
});
Script>

Page:

The code is as follows Copy Code


<div class= "Demo" >
<div id= "Dialog" title= "Basic dialog box" >
<p>
This is a dialog box where the window can be moved, scaled and closed by the "X" icon </p>
</div>
<button id= "Opener" >
Open the dialog box </button>
</div>

<div class= "Demo" >
<div id= "Dialog" title= "Basic dialog box" >
<p>
This is a dialog box where the window can be moved, scaled and closed by the "X" icon </p>
</div>
<button id= "Opener" >
Open the dialog box </button>
</div>

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.