Artdialog is a plug-in of jquery's ultra-lightweight pop-up dialog box. Let's introduce how to use artdialog.
Recently, I started to learn about the jQueryEasyUi framework. Now I just learned the basics. I have the following knowledge about its pop-up box:
Import on the page
The Code is as follows: |
Copy code |
<Script src = "js/artDialog4.0.2/artDialog. source. js? Skin = gray "> </script> <Script src = "js/artDialog4.0.2/artDialog. iframeTools. js"> </script> |
The two JavaScript codes can be used to construct the desired Dialog window. The test example is as follows:
Write a button and click to implement the following functions:
The Code is as follows: |
Copy code |
Function openPage (){ Var setting = {href: #, title: 'test', width: 650, height: 380, scrolling: no }; Setting. href = 'path to open the interface '; // Data can be used to transmit data to the current page. Art. dialog. data ('key', value ); // Open the window Art. Dialog. open (setting. href, setting ); } |
After the above functions are implemented, you can open the window you want.
In the following interface:
The Code is as follows: |
Copy code |
Var value = art. dialog. data ('key '); |
Get the value you want to pass
To refresh the father page:
The Code is as follows: |
Copy code |
Var win = art. dialog. open. origin; Win. location. reload (); |
1. Use traditional parameters
The Code is as follows: |
Copy code |
Art. dialog (content, OK, cancel) |
Art. dialog ('simple and pleasant interface, powerful expressiveness, elegant internal implementation ', function () {alert ('yes') ;}); run»
2. Use literal parameters
The Code is as follows: |
Copy code |
Art. dialog (options) Var dialog = art. dialog ({ Title: 'Welcome ', Content: 'Welcome to the artDialog dialog box component! ', Icon: 'sudoed ', Follow: document. getElementById ('btn2 '), OK: function (){ This. title ('Warning '). content (' Please note that artDialog will be disabled in two seconds! '). Lock (). time (2 ); Return false; } }); |
The following is a js form that pops up through artdialog and is submitted through ajaxform (The form can be verified using the jquery validate verification control)
The Code is as follows: |
Copy code |
$ (Document). ready (function (){ Var options = { Target: '# output2 ', Success: showResponse // post-submit callback }; $ ('# MyForm'). ajaxForm (options ); Var alt = null; $ ("# AddHname"). click (function (){ Alt = art. dialog ({ Title: 'add nickname ', Content: document. getElementById ('G _ cn '), Width: 750, Button :[ { Name: 'save ', Focus: true, Callback: function (){ $ ('# MyForm'). submit (); Return false; } }, { Name: 'close ', Callback: function (){ } } ] }); }); Function showResponse (data ){ If (alt! = Null ){ Alt. close (); } If (data = 'success '){ ArtDialog. alert ('saved successfully '); } Else { Art. dialog. close (); ArtDialog. alert ('failed to save '); } } }); |