JQuery Alert Dialogs Plugin Version 1.0
Plugin Download Address: http://abeautifulsite.net/notebook/87
the original method of oneself is:
Copy Code code as follows:
Usage:
Jalert (message, [title, callback])
JCONFIRM (message, [title, callback])
JPROMPT (message, [value, title, callback])
1. A new public method of Multicheckbox:
Public methods
Multicheckbox:function (message, value, title, callback) {
if (title = = null) title = ' Multicheckbox ';
$.alerts._show (title, message, Value, ' Multicheckbox ', function (result) {
if (callback) callback (result);
});
},
2. In the private method _show: Increase control of multicheckbox in function (title, MSG, value, type, callback) {...}:
Private methods
------------------------Key Parts------------------------------
Case ' Multicheckbox ':
$ ("#popup_message"). Append (Value). After (' <div id= "Popup_panel" > <span id= "checkall" style= "Cursor:pointer border:1px Solid #FFCC35 font-family: Song body, font-weight:bold;background-color: #FFFF99; color: #0000CC; margin:3px; padding:3px 10px 3px 10px; " > </span> <span id= "Popup_ok style=" cursor:pointer;border:1px #CF4342; solid: XXFarEastFont-Arial; Font-weight:bold;background-color: #DFF1FF; color: #CF4342; margin:3px;padding:3px 10px 3px 10px; " > Confirm </span> <span id= "Popup_cancel" style= "cursor:pointer;border:1px solid #CF4342; font-family: XXFarEastFont-Arial; Font-weight:bold;background-color: #DFF1FF; color: #0000CC; margin:3px;padding:3px 10px 3px 10px; " > Cancel </span></div> ');
var $spanHover = $ ("#dialog span");
$spanHover. Hover (
Function () {$ (this). addclass ("Spanmousehover");
Function () {$ (this). Removeclass ("Spanmousehover");
);
$ ("#checkall"). Click (function () {
if ($ ("#checkall"). HTML () = "All selected") {
$ ("#dialog input"). each (function () {$ (this). attr ("Checked", true);});
$ ("#checkall"). HTML ("deselect All");
}
else {
$ ("#dialog input"). each (function () {$ (this). attr ("checked", false);});
$ ("#checkall"). HTML ("Select All");
}
});
$ ("#delcheckall"). Click (function () {
$ ("#dialog input"). each (function () {$ (this). attr ("checked", false);});
});
$ ("#popup_ok"). Click (function () {
var getAll = "";
var test = $ (' #dialog input '). each (the function () {if (this. checked) {GetAll + = $ (this). Val () + ', ';}});
var valback = getall.substring (0, getall.length-1);//Remove the last ', ' number
$.alerts._hide ();
$ ("#ctl00_ContentPlaceHolder_main_TextBox_recever_sel"). blur ();
if (callback) callback (valback);//After clicking OK, upload all the selected content to the input box
});
$ ("#popup_cancel"). Click (function () {
$.alerts._hide ();
$ ("#ctl00_ContentPlaceHolder_main_TextBox_recever_sel"). blur ();
if (callback) callback (NULL);
});
/ /----------------------------------------------------------------------
Add the following name to the//Shortuct functions:
Jmulticheckbox = function (message, value, title, callback) {
$.alerts.multicheckbox (message, value, title, callback);
};
3. The following script is invoked in the onfocus attribute of the input input box (or asp:textbox) of the preceding code:
Jmulticheckbox (', ' <% = Allcheckinfo. ToString ()%> ', ' Select receiving Department ', function (r) {
Define incoming HTML elements, pop-up main headings, callback results (that is, selected content)
if (r!=null)
$ (' #ctl00_ContentPlaceHolder_main_TextBox_recever_sel '). Val (R);
});
Which "Allcheckinfo. ToString () can be a result that is taken out of the corresponding business logic in the background, such as:
StringBuilder allinfo = new StringBuilder ("");
Allinfo. Append ("<div id=\" dialog\ "style=\" padding:0; margin:0;height:250px;width:280px;text-align:left;line-height : 20px;overflow:auto\ ">");
...
while (Oracledatareader.read ())
{
String bumeninfo = Oradr[0]. ToString ();
Allinfo. Append ("<span class=\" spanmouse\ "><input name=\" chk1\ "type=\" checkbox\ "id=\" C "+ flag +" \ "value=\" "+ Bumeni NFO + "\"/><label for=\ "C" + flag + ">" + bumeninfo + "</label></span><br/>");
}
...
Allinfo. Append ("</div>");
Will <div>...</div> return to JS, the final effect is as follows: