条件判断中定义两个$.confirm();但是每次第一个执行完之后,不刷新的情况下,第二个无法执行。

sxn891128 2015-12-07 10:49:05
var status = $(".closeBtn").attr('tag');
alert(status);
console.log(status+ "====del after");
/**20151202======begin**/
if(status == 1){
infoConfirm(function(){
});
return;
}else{
$.confirm({
'title' : '提示',
'message' : '删除*****发布。<br /><br />确认删除?',
'buttons' : {
'删除' : {
'class' : 'blueBtn',
'action': function(){
// deleteEndpoint();
}
},
'暂不' : {
'class' : 'grayBtn ml40',
'action': function(){} // Nothing to do in this case. You can as well omit the action property.
}
}
});


其中infoConfirm()也是一个弹出框,当状态为1时,提示不能删除。

function infoConfirm(success) {
$.confirm({
'title' : '温馨提示',
'message' : '数据****才能进行修改!',
'buttons' : {
'关闭' : {
'class' : 'grayBtn ml40',
'action': function(){} // Nothing to do in this case. You can as well omit the action property.
}
}
});
}

但是,每次弹出温馨提示后,,即使将状态更改为0,if分支执行到删除提示框时,依旧加载的是温馨提示的confirm。。有没有什么方法,可以不在每次刷新的同时,分别弹出两个confirm框。。
...全文
620 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
sxn891128 2015-12-07
  • 打赏
  • 举报
回复
好像不刷新的话,confirm就不再进行加载了。直接读取的缓存数据。。
sxn891128 2015-12-07
  • 打赏
  • 举报
回复
在线等,,急,。没有人么。
  • 打赏
  • 举报
回复
弄成一个函数,传递state进去就好了,需要的时候调用一次函数
//////////Test
doAlert(0);

setTimeout(function(){doAlert(1);},5000)

////////////
function doAlert(state){
//var status = $(".closeBtn").attr('tag');
        alert(status);
        console.log(status+ "====del after");
        /**20151202======begin**/
        if(status == 1){
            infoConfirm(function(){
            });
            return;
        }else{
            $.confirm({
                'title'    : '提示',
                'message' : '删除*****发布。<br /><br />确认删除?',
                'buttons' : {
                    '删除' : {
                        'class' : 'blueBtn',
                        'action': function(){
                         //   deleteEndpoint();
                        }
                    },
                    '暂不' : {
                        'class' : 'grayBtn ml40',
                        'action': function(){} // Nothing to do in this case. You can as well omit the action property.
                    }
                }
            });
}

87,992

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧