admin管理员组文章数量:1410712
I'm working on a modal ment system using jQuery and jQuery UI, but I'm having some issues with focus. I have a series of divs inside the modal to switch between Login and Add ment, as below:
<div id="modal" title="Loading">
<div id="modalContent"></div>
<div id="modalLogin">
<div class="loginBox"></div>
<div class="addCommentBox"></div>
<div class="mentReview"></div>
</div>
</div>
Inside of the addCommentBox div, I've got the ment code:
<form action="/ments/add" class="addCommentForm" name="addCommentForm" method="post">
<textarea name="content" class="addCommentContent"></textarea>
<button value="Add Comment" type="submit" class="mentPost"/>
<button value="Clear Comment" type="submit" id="clearComment"/>
</form>
The issue is that about half the time after opening the dialog the textarea inside the addCommentBox
div doesn't react to keyboard inputs when selected. The mouse works correctly and will allow text to be selected, but keyboard control does nothing.
I have no event listeners on the textarea. I've got some on the buttons, but they are targeting only the buttons.
The only thing that happens in the HTML seems to be the fact that every time I click on the modal, the z-index increases for the overall modal div. I have set the addCommentBox
div to have a z-index of 9999, greater than the z-index of the modal.
Any suggestions or directions to research would be greatly appreciated. Thanks!
I'm working on a modal ment system using jQuery and jQuery UI, but I'm having some issues with focus. I have a series of divs inside the modal to switch between Login and Add ment, as below:
<div id="modal" title="Loading">
<div id="modalContent"></div>
<div id="modalLogin">
<div class="loginBox"></div>
<div class="addCommentBox"></div>
<div class="mentReview"></div>
</div>
</div>
Inside of the addCommentBox div, I've got the ment code:
<form action="/ments/add" class="addCommentForm" name="addCommentForm" method="post">
<textarea name="content" class="addCommentContent"></textarea>
<button value="Add Comment" type="submit" class="mentPost"/>
<button value="Clear Comment" type="submit" id="clearComment"/>
</form>
The issue is that about half the time after opening the dialog the textarea inside the addCommentBox
div doesn't react to keyboard inputs when selected. The mouse works correctly and will allow text to be selected, but keyboard control does nothing.
I have no event listeners on the textarea. I've got some on the buttons, but they are targeting only the buttons.
The only thing that happens in the HTML seems to be the fact that every time I click on the modal, the z-index increases for the overall modal div. I have set the addCommentBox
div to have a z-index of 9999, greater than the z-index of the modal.
Any suggestions or directions to research would be greatly appreciated. Thanks!
Share Improve this question asked Jan 27, 2010 at 16:53 Andrew AndersonAndrew Anderson 4414 silver badges14 bronze badges 4- 1 please provide an example failing: jsfiddle – Markus Commented Apr 19, 2011 at 17:04
- 1 you mite want to add which jQuery UI version, which jQuery version. – potatopeelings Commented Apr 20, 2011 at 6:10
- you might want to check the z-index of the overlay too $(".ui-widget-overlay").css("z-index") – potatopeelings Commented Apr 20, 2011 at 6:28
- This particular problem is over a year old, the project has been live without issue for roughly that amount of time, and I've been unable to replicate the issue. Sorry, but this question is officially nil for me. What's the convention on Stack Overflow to take care of this? – Andrew Anderson Commented Apr 22, 2011 at 15:11
5 Answers
Reset to default 1If it's happening "half the time" that's a hard one. Test it on some other browsers to see if the same thing happens.
How are you hiding loginBox and mentReview? If you're using opacity it may be that something you can't see is sitting on top of the textarea.
You won't see elements with opacity of 0, but they're still there in every other respect. They will accept mouse events, stopping you from clicking on the textarea.
If you can see the textarea, then it doesn't sound like a z-index issue to me.
When opening the dialog, try focusing the textbox during on the "open" function.
$('#modal').dialog({ open: function () { $('textarea[name=content]').focus(); } });
Sounds like the problem is with something else on the page. Have you tested this by putting the above feature it's own page separate from all other functionality?
Try setting the TABINDEX property of the textarea if it's not set.
本文标签: javascriptjQuery UI Dialog and Textarea Focus IssueStack Overflow
版权声明:本文标题:javascript - jQuery UI Dialog and Textarea Focus Issue - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744981049a2635817.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论