本文介绍了确认来自alertify插件和jquery的框的返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我的表单有确认对话框。它是在一个jQuery的提交功能。我正在使用alertify显示确认对话框。但问题是我的jQuery提交函数在alertify获取确认框值之前返回。阅读该警报是不阻塞的。任何方式来克服这一点,并将确认框的值返回到我的表单? $(#viewform)。submit (e){ if(e) return true; $ b alertify.confirm(删除所选条目? $ b else 返回false; }); }); 函数总是返回true。我想返回确认框的输出。如何返回确认框的延迟返回值? 解决方案一个解决方法是使用按钮而不是提交输入,然后使用点击监听器运行alertify。这可以通过jQuery提交表单。以下是它的外观: HTML: < form ID = 形式 > < input type =buttonvalue =Submitid =btn> < / form> JavaScript: alertify.confirm(Delete the selected entry?,function(e){ if(e){ $('#form')。submit(); return true; } else { return false; } } ); }); I have a confirm dialog for my form. it is inside a jquery submit function. I am using alertify to show the confirm dialog. But problem is my jquery submit function returns before alertify gets the confirm box value. Read that alertify is non blocking. Any way to overcome this and return the confirm box value back to my form?$("#viewform").submit(function(){ alertify.confirm("Delete the selected entry?",function(e){ if(e) return true; else return false; }); });The function always returns true. I want to return the output of confirm box. How can i return the delayed return value of confirm box? 解决方案 One work around would be to used a button rather than a submit input, then use a click listener to run alertify. This could then submit your form via jQuery. Here's how it might look:HTML: <form id="form"> <input type="button" value="Submit" id="btn"></form>JavaScript:$('#btn').click(function() { alertify.confirm("Delete the selected entry?",function(e){ if(e) { $('#form').submit(); return true; } else { return false; } });}); 这篇关于确认来自alertify插件和jquery的框的返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-18 10:23