牛骨文教育服务平台(让学习变的简单)
博文笔记

jquery-confirm应用 alert confirm 弹出 弹窗

创建时间:2017-03-08 投稿人: 浏览次数:7385

引用地址

<link href="//cdn.bootcss.com/jquery-confirm/3.1.0/jquery-confirm.min.css" rel="stylesheet">
<script src="//cdn.bootcss.com/jquery-confirm/3.1.0/jquery-confirm.min.js"></script>
<script>

alert

$.alert({
      type:"red",
      title: "系统提示",
      content: content,
      icon:"glyphicon glyphicon-info-sign"
    });

简单的confirm

$.confirm({
      title: "系统提示",
      content: "确认要删除吗?",
      type:"red",
      icon:"glyphicon glyphicon-question-sign",
      buttons: {
        ok: {
            text: "确认",
            btnClass: "btn-primary",
            action: function(){
              $.post(`{:url("Index/deleteurl")}`, {url_id: url_id}, function(data, textStatus, xhr) {
                if (data["status"] ==1) {
                  location.reload();
                }else{
                  showNotice("删除失败");
                }
              });
            }
        },
        cancel: {
            text: "取消",
            btnClass: "btn-primary",
            action: function(){
                // button action.
            }
        },
      }
    });

大点的confirm

$.confirm({
      title: "系统提示",
      columnClass:"col-md-8 col-md-offset-2",
      content: "aaaaaaaaaaa<br><br><br><br>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa12",
      // content: "url:text.txt",
      contentLoaded: function(data, status, xhr){
        // data is already set in content
        this.setContentAppend("<br>Status: " + status);
      },
      type:"red",
      icon:"glyphicon glyphicon-question-sign",
      buttons: {
        ok: {
            text: "确认",
            btnClass: "btn-primary",
            action: function(){
              $.post(`{:url("Index/deleteurl")}`, {url_id: url_id}, function(data, textStatus, xhr) {
                if (data["status"] ==1) {
                  location.reload();
                }else{
                  showNotice("删除失败");
                }
              });
            }
        },
        cancel: {
            text: "取消",
            btnClass: "btn-primary",
            action: function(){
                // button action.
            }
        },
      }
    });

同步等待请求结果返回后再处理

$.confirm({
      title: "添加游戏",
      columnClass:"col-md-8 col-md-offset-2",
      content: "url:"+"{:url("Pay/product_list")}"+"?add=1",
      type:"red",
      icon:"glyphicon glyphicon-question-sign",
      buttons: {
        ok: {
            text: "确认",
            btnClass: "btn-primary",
            action: function(){
                var postdata = $("#addgame_form").serialize();
                postdata += "&add=1";
                var flag = true;
                $.ajax({
                    type: "POST",
                    url: "{:url("Pay/product_list")}",
                    data: postdata,
                    async: false,
                    success: function(data){
                        if (data["code"] ==1) {
                          showNotice(data["msg"]);
                          datagridReload();
                        }else{
                          showNotice(data["msg"]);
                          flag = false;
                        }
                    }
                });
                if (!flag){
                    return false
                }
            }
        },
        cancel: {
            text: "取消",
            btnClass: "btn-primary",
            action: function(){
                // button action.
            }
        },
      }
     });

参考
http://www.html580.com/12067/demo
http://www.jq22.com/demo/jqueryConfirm20160413/

声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。