首页 > 其他分享 >layui弹框提示按回车事件一直不停弹窗

layui弹框提示按回车事件一直不停弹窗

时间:2023-11-10 11:56:37浏览次数:28  
标签:function layer return layui 弹框 msg 弹窗 icon

如下界面,敲回车后一直不停弹窗,确定的事件也不执行

 解决问题方法:在确认事件前面加上$(':focus').blur();如下所示,问题得到解决

$(':focus').blur();
layer.confirm(msg,{
icon: 3,
title:'提示',
success:function(){
this.enterEsc = function (event) {
if (event.keyCode === 13) {
$(".layui-layer-btn0").click();
return false; //阻止系统默认回车事件
}else if(event.keyCode == 27){
$(".layui-layer-btn1").click();
return false;
}
};
$(document).on('keydown', this.enterEsc); //监听键盘事件,关闭层
},

}, function (index) {
//点击确定后要执行的代码
//var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
//提交 Ajax 成功后,关闭当前弹层并重载表格
var ajaxTimeoutTest1 = $.ajax({
url: "https://api.son.com/sh/do",
dataType:"json",
async:true,
timeout: 5000,
data:data.field,
type:"post",
success:function(res){
if(res.hasOwnProperty('error')){
initAwardList()
return layer.msg(res.error.message,{time:1*2000,icon:5},function(){})
}
layer.closeAll('loading');
//请求成功时处理
if (res.result.return_code === 'SUCCESS'){
layer.msg(res.result.return_msg,{time:1*1000,icon:6},function(){
parent.layui.table.reload('currentTableId'); //重载表格
initAwardList()
});
}else{
layer.msg('转账失败,请确认数据是否异常。。。',{time:1*2000,icon:5},function(){

});
}
},
complete:function(XMLHttpRequest, status){
if(status=='timeout'){
ajaxTimeoutTest1.abort();
layer.msg('网络不稳定',{time:1*2000,icon:5},function(){});
}
},
error:function(){
//请求出错处理
layer.closeAll('loading');
layer.msg('转账失败,请确认数据是否异常。。。',{time:1*2000,icon:5},function(){});
}
});
layer.close(index); //执行完后关闭
$("#amount").focus()
},function (index){
layer.close(index); //执行完后关闭
$("#amount").focus()
});

标签:function,layer,return,layui,弹框,msg,弹窗,icon
From: https://www.cnblogs.com/buckliu/p/17823778.html

相关文章

  • elementplus弹窗可拖拽draggable,点击空白处不消失close-on-click-modal,modal是否去掉
    <el-dialog:modal="false"v-model="dialogVisible"title=""width="30%"draggable:close-on-click-modal="false"class="message-dialog"></el-dialog&g......
  • layui下拉框可手动输入
    先看效果layui版本:[email protected]代码:<divclass="layui-form-item"><labelclass="layui-form-label">关键词:</label><divclass="layui-input-block"><!--lay-verify="required"-->......
  • 在Mac上关闭Microsoft AutoUpdate 弹框提示
    1、打开terminal终端,输入文件地址 cd/Library/Application\Support/Microsoft/MAU2.0 2、将此应用程序权限设置为000,输入密码sudochmod000Microsoft\AutoUpdate.appPassword:  3、完成(如下) TRANSLATEwithxEnglishArabicHebrewPolish......
  • elementUI确认消息弹框区分取消和关闭按钮
    预期效果:说明:默认情况下,elementUI的确认消息弹框中取消按钮和右上角关闭按钮,走的是同一个方法,也就是catch方法的回调,如果项目中有区分,默认的是无法支持的。所以要重新配置一下,话不多说,上代码://res.msg表示提示信息内容this.$confirm(res.msg,'提示',{con......
  • Layui自定义icon图标
    在使用Layui进行开发时,会使用:<iclass="layui-icon">&#xe60c;</i>或者<iclass="layui-iconlayui-icon-face-smile"style="font-size:30px;color:#1E9FFF;"></i>进行图标的引入,但是官方给的图标毕竟有限,有时候没有自己想要的,但在阿里巴巴矢量图标库(ht......
  • 关于在页面列表里查询数据的时间和页面实时弹窗中的时间差1秒钟的问题
    1、问题:在一次告警中心功能的演示时,告警列表页中的实时告警数据,每次都跟弹窗的告警提示信息查一秒,有时候有事正常的,就很奇怪。2、解决:经过进行代码断点,发现在插入告警时间时,使用的LocalDateTime,该时间时带有纳秒时间的,比如在程序中显示的时间值是:1990-01-01T00:01:01.111,此时存......
  • 去除WinForm程序中的Devexpress弹窗
    去除WinForm程序中的Devexpress弹窗///<summary>///应用程序的主入口点。///</summary>[STAThread]staticvoidMain(){if(!CheckInstance()){Application.Exit();......
  • uniapp微信小程序自定义隐私权限弹窗
    插件地址:https://ext.dcloud.net.cn/plugin?id=14576#detail 样式小改动<template><viewclass="xh-privacy"><!--默认主题--><view:style="'background:'+background+';'"class="the......
  • BIP保存前出现弹框 阻止保存 点击修改后,再继续保存事件
    viewModel.on("beforeSave",function(args){letpromise=newcb.promise();cb.utils.confirm(title:"是否保存?",okText:"修改",cancelText:"不修改",function(){if(true){promise.rej......
  • layui-form 提交按钮不生效
    有时候layui-form不生效是因为div的层级关系错误造成的,比如把提交按钮放在了div的外部了;欢迎关注公-众-号【TaonyDaily】、留言、评论,一起学习。Don’treinventthewheel,librarycodeistheretohelp.若有帮助到您,欢迎点赞、转发、支持,您的支持是对我坚持最好的肯定(_)你要......