jQuery UI modal dialog captures all keypress so I can't input text inside it

蓝咒 提交于 2019-12-03 09:49:20

The z-index is the problem. Here is an exemple ( http://jsfiddle.net/c3BPP/ ) of your code with a bigger z-index and it works.

You can also lower the z-index of the JQuery dialog:

var dialog = $('#modal-dialog').dialog({ 
    modal: true,
    zIndex: 500
});

By default, it is 1000. Of course your relative or absolute positioned elements needing text input need to be greater than the z-index of the dialog still.

I found that the <form> tag in my dialog was getting a z-index of 1, preventing any of the controls from working. Instead of changing the z-index for each control, simply changing the z-index of the <form> tag to 1010 (a value higher than the default of the dialog) worked for me.

user3761700

Adding tabindex="-1" helped me resolve this problem.

Here's an example:

 <div class="modal fade" tabindex="-1" id="error" role="dialog">
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!