Simple implementation of the jquery Encapsulated dialog box

Source: Internet
Author: User
This article for you to introduce the use of jquery simple implementation of the Package dialog box, the implementation of the Code as follows, interested friends can refer to ha, I hope to help you copy code code as follows:




var _alert_iconcss = "Tipmsg_icoinfo";


var _confirm_iconcss = "Tipmsg_icoconfirm";


var _error_iconcss = "Tipmsg_icoerror";


var _warning_iconcss = "Tipmsg_icowarning";


function Dialoginit (type, msg) {


var iconcss = "";


switch (type) {


case "Confirm": Iconcss = _confirm_iconcss; Break


case "Error": Iconcss = _error_iconcss; Break


case "Warning": Iconcss = _warning_iconcss; Break


default:iconcss = _alert_iconcss; Break


}





var htmlstr = "<div id= '" + type + "div ' style= ' display:none; ' ><p><span class= ' "+ iconcss +" ' style= ' float:left; margin:0 7px 50px 0;width:35px;height:35px; ' ></span> "+ msg + </p></div>";


return htmlstr;


}


function Alert (msg, okcallback) {


var title = "Hint";


var type = "Alert";


var html = dialoginit (type, msg);


var div = $ (' body '). Find ("#" +type+ "div");


Div.remove ();


$ (' body '). Append ($ (HTML));





var buttons = {ok: function () {


if (okcallback) Okcallback ();


$ (this). dialog ("Close");


}


};





$ ("#" +type+ "Div"). Dialog ({


Modal:true,


Title:title,


buttons:buttons


});


}


function Confirm (msg, Okcallback, cancelcallback) {


var title = "Confirmation";


var type = "Confirm";


var html = dialoginit (type, msg);


var div = $ (' body '). Find ("#" +type+ "div");


Div.remove ();


$ (' body '). Append ($ (HTML));





var buttons = {ok: function () {


if (okcallback) Okcallback ();


$ (this). dialog ("Close");


},


"Cancel": function () {


if (cancelcallback) Cancelcallback ();


$ (this). dialog ("Close");


}


};


$ ("#" +type+ "Div"). Dialog ({


Modal:true,


Title:title,


buttons:buttons


});


}


function Error (msg, okcallback) {


var title = "Error";


var type = "Error";


var html = dialoginit (type, msg);


var div = $ (' body '). Find ("#" +type+ "div");


Div.remove ();


$ (' body '). Append ($ (HTML));





var buttons = {ok: function () {


if (okcallback) Okcallback ();


$ (this). dialog ("Close");


}


};





$ ("#" +type+ "Div"). Dialog ({


Modal:true,


Title:title,


buttons:buttons


});


}


function Warning (msg, okcallback) {


var title = "Warning";


var type = "Warning";


var html = dialoginit (type, msg);


var div = $ (' body '). Find ("#" +type+ "div");


Div.remove ();


$ (' body '). Append ($ (HTML));





var buttons = {ok: function () {


if (okcallback) Okcallback ();


$ (This). dialog ("Close");


}


};





$ ("#" +type+ "Div"). Dialog ({


Modal:true,


Title:title,


buttons:buttons


});





}

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.