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

Rost picture Rost · Aug 4, 2011 · Viewed 13.3k times · Source

I create modal dialog with form inside it (with some text input). And I just can't enter the text inside the textbox. Dialog blocks keyboard input.

Here is my simplified example:

<div id="modal-dialog">
    <label for="my-text">TRY to input text...</label>
    <textarea id="my-text" style="position:relative; z-index:1"></textarea>
</div>
<script type="text/javascript">
    var dialog = $('#modal-dialog').dialog({ modal: true });
</script>

Note: You may ask - why did I mentioned about "position:relative; z-index:1"? Because it works fine without it. But I can't remove it because of design.

Note: not modal dialog works fine too.

I'm using jQuery 1.6.2 + jQuery UI 1.8.14

Answer

David Laberge picture David Laberge · Aug 5, 2011

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.