无法在 ModalWindow 中更改 IE 11 中的文本框值

Cannot change text box value in IE 11 in a ModalWindow

我可以在 ModalWindow 的文本框中单击文本并进行编辑。当我保存然后重复该过程时,我无法单击文本框中的文本并进行更改。

这只发生在 IE 11 中。我可以单击 X 清除文本框,然后设置一个值,但我不应该这样做。我不确定我的代码、IE 11 或 Wicket 是否存在问题。我的快速入门使用的是 Wicket 7.0.0,但我在 Wicket 6.18.0 中有类似的行为。

这里是我的IE 11版本 运行:

以下是我在 Wicket 快速入门中使用的步骤:

  1. 在主页中,单击 "openWindowLink"
  2. 模态窗口打开。单击文本框中的文本并进行编辑。单击保存。
  3. 模态窗口关闭。再次单击 "openWindowLink"。
  4. 模态窗口打开。单击文本框中的文本并尝试进行编辑。
  5. 观察到您无法单击文本并获得光标进行编辑。

以下是我认为相关的快速入门部分:

HomePage.java

    @Override
    public void onInitialize()
    {
        super.onInitialize();

        final ModalWindow modal = new ModalWindow("modal");
        modal.setPageCreator(new ModalWindow.PageCreator()
        {
            private static final long serialVersionUID = 1L;

            public Page createPage()
            {
                return new IEModalPage();
            }
        });
        add(modal);

        add(new AjaxLink<Void>("openWindowLink")
        {
            private static final long serialVersionUID = 1L;

            public void onClick(AjaxRequestTarget target)
            {
                modal.show(target);
            }
        });
    }

HomePage.html

    <body>
        <a wicket:id="openWindowLink">Click to open the modal window</a>
        <div wicket:id="modal"></div>
    </body>

IEModalPage.java

public class IEModalPage extends WebPage
{
    private static final long serialVersionUID = 1L;
    private String value = "clickme";

    @Override
    public void onInitialize()
    {
        super.onInitialize();

        Form<Void> form = new Form<Void>("pageForm");
        add(form);

        form.add(new TextField<String>("captureValue", new PropertyModel<String>(this, "value")));

        form.add(new AjaxSubmitLink("saveButton")
        {
            private static final long serialVersionUID = 1L;

            @Override
            public void onSubmit(AjaxRequestTarget target, Form<?> form)
            {
                System.out.println(value);
                ModalWindow.closeCurrent(target);
            }
        });
    }
}

IEModalPage.html

<body>
    <form wicket:id="pageForm">
        Click in the text box and make sure you see a cursor: <input type="text" wicket:id="captureValue" />
        <br />
        <input type ="submit" value="Save" wicket:id="saveButton" />
    </form>
</body>

这种情况的解决方案是使用变通方法来关注第一个可用的文本框。在此示例中,我仅在用户使用 IE 11 时添加此焦点功能。在我的基本模式页面中:

@Override
public void renderHead(IHeaderResponse response)
{
    response.render(JavaScriptHeaderItem.forScript(
        "if (Object.hasOwnProperty.call(window, 'ActiveXObject') && !window.ActiveXObject) {" +
        "   $(document).ready(function(){$('input[type=text]').first().focus();});" +
        "}",
        "IE11Focus"));
}