jquery-confirm
目录
- 更多分享:www.catbro.cn
-
引入资源
<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. } }, } });