JQuery UI Landscaping Confirm code

Source: Internet
Author: User
Today, in the improvement of the project to participate in a national competition, found that the use of a large number of alert and comfirm, so I want to achieve a pop-up graphical dialog box, which will become very friendly, because time is not much, directly paste code, share
View Sourceprint?
//当页面加载完毕时添加一个隐藏的div
$(function(){
   varboardDiv = "<div id='message' style='display:none;'><span id='spanmessage'></span></div>";
   $(document.body).append(boardDiv);
 
});
//只是提示信息alert
   functionmessage(text) {
       $("#spanmessage").text(text);
       $("#message").dialog({
           title:"企业信息管理系统,提示您",
           modal: true,
           buttons: {
               "确定": function() {
                   $(this).dialog("close");
               }
           }
       });
   }
   //类似于confirm的功能
   //说明callback是如果要选择是,要执行的方法
   functionqueren(text, callback) {
       $("#spanmessage").text(text);
       $("#message").dialog({
           title: "企业信息管理系统,提示您",
           modal: true,
           resizable: false,
           buttons: {
               "否": function() {
                   $(this).dialog("close");
               },
               "是": function() {
                   callback.call();//方法回调
                   $(this).dialog("close");
               }
           }
       });
   }
Using the example (an example of a static deletion feature)
1, first reference jquery Couroux (<script src= "http://www.cnblogs.com/js/jquery-1.4.2.js" type= "text/Web Effects" ></script>)
2. In reference to the jquery UI Library
<link href= ". /css Tutorial/css/ui-lightness/jquery-ui-1.8.2.custom.css "rel=" stylesheet "
Type= "Text/css"/>
<script src= ". /js/jquery-ui-1.8.2.custom.min.js "type=" Text/javascript "></script>
3, write processing code
View Sourceprint?
$("a[delete=true]").click(function() {
               var id = $(this).attr("curId");
               queren("确认要删除吗?", function() {
                   $.post("productDel.ashx", { "action": "delete", "id": id }, function(data, status) {
                       if(data == "ok") {
                           message("删除成功!");
                           $("a[curId='"+ id + "']").parent().parent().parent().parent().remove();
                       }
                   });
               });
           });
See how it works (No art yet)

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.