简体   繁体   English

启用模式叠加时,将焦点集中到弹出输入

[英]focus to popup input when modal overlay is active

I have this peculiar situation. 我有这种特殊的情况。 First, there's a modal and the rest of the page is hidden by overlay: 首先,有一个模态,页面的其余部分被叠加层隐藏:

<div class="overlay"></div>
.overlay {
 position: fixed;
 width: 100%;
 height: 100%;
 visibility: hidden; //visible when modal pops up of course
 top: 0;
 left: 0;
 z-index: 2900;
}

Inside modal there are some elements which have the following event listener: 模态内部有一些具有以下事件侦听器的元素:

el.find('select').on('mousedown', function (e){
    if (event.which === 3) {
    ...popup window containing contenteditable div gets formed and added to modal, it gets el boundingClientRect data to sit tight on it. So far so good, but - 
    popup.focus();

does not work. 不起作用。 Tried js+jquery and placing popup anywhere on page, but nada. 尝试过js + jquery并在页面上任何地方放置弹出窗口,但不适用。 Its not the console question either. 它也不是控制台问题。 Triggering a click on popup has zero results. 触发点击弹出窗口的结果为零。 When I remove overlay all works. 当我删除覆盖所有作品。 Can't figure out the reason... 无法找出原因...

To reiterate the layers - there's the rest of the page covered by overlay, on that sits a modal (z-index:3000) and popup is called onto it(z-index:3010). 要重申这些层-页面的其余部分都被叠加层覆盖,在该页面上放置了一个模式(z-index:3000),并在其上调用了弹出窗口(z-index:3010)。

Edit: now here's the fiddle - https://jsfiddle.net/zumbauuo/ 编辑:现在这是小提琴-https: //jsfiddle.net/zumbauuo/

Problem persists. 问题仍然存在。 Yesterday in original document I was able to get popup focused with this code when removing overlay div and keeping modal structure, today however - not. 昨天,在原始文档中,当删除覆盖div并保持模态结构时,我能够使此代码集中弹出窗口,但是今天却不行。 So I don't know what to think any more. 所以我不知道该怎么想了。

请试试:

.on( "change", handler )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM