在输入按键时避免模态关闭 [英] Avoid modal dismiss on enter keypress

查看:124
本文介绍了在输入按键时避免模态关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在里面设置了一个引导模式,我只是注意到当我按下回车键时,模态被取消了。
有没有办法在按Enter键时忽略它?

I have set up a bootstrap modal with a form inside it, I just noticed that when I press the Enter key, the modal gets dismissed. Is there a way not to dismiss it when pressing Enter?

我尝试用键盘激活模式:false,但只能用ESC键禁止解除。

I tried activating the modal with keyboard:false, but that only prevents dismissal with the ESC key.

推荐答案

我也遇到了这个问题。

我的问题是我有一个关闭按钮我的模式

I just had this problem too.
My problem was that i had a close button in my modal

<button class="close" data-dismiss="modal">&times;</button>

在输入字段中按回车会导致此按钮被触发。我将它改为了一个锚点,而且它现在按预期工作(输入提交表单并且不关闭模式)。

Pressing enter in the input field caused this button to be fired. I changed it to an anchor instead and it works as expected now (enter submits the form and does not close the modal).

<a class="close" data-dismiss="modal">&times;</a>

没有看到您的来源,我无法确认您的原因是否相同。

Without seeing your source, I can't confirm that your cause is the same though.

这篇关于在输入按键时避免模态关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆