简体   繁体   English

SheerResponse没有关闭

[英]SheerResponse doesn't close

This is part of a Sitecore 8 Update 2 MVC website, i'm extending the TreelistEx field 这是Sitecore 8 Update 2 MVC网站的一部分,我在扩展TreelistEx字段

I've created a sheerrepsonse modaldialog, called by this code. 我创建了一个Sheerrepsonse模态对话框,此代码称为。

namespace be.absi.kbs.extensions
{
   class AbsiTreeListEx : TreelistEx, IMessageHandler
   {

   void IMessageHandler.HandleMessage(Message message)
    {
        if (message == null)
        { return; }

        if (message["id"] == null)
        { return; }

        if (!message["id"].Equals(ID))
        { return; }

        var fieldInfo = _fieldInformation[message["id"]];

        switch (message.Name)
        {
            case "treelist:edit":
                var nvcEdit = new NameValueCollection { { "source", fieldInfo.Source } };
                Sitecore.Context.ClientPage.Start(this, "Edit", nvcEdit);
                break;

            case "absitreelistex:absiadd":
                var nvcAdd = new NameValueCollection {{"clientFieldId",  message["id"] } };
                Sitecore.Context.ClientPage.Start(this, "AddItem", nvcAdd);
                break;
        }
    }

    protected void AddItem(ClientPipelineArgs args)
    {
        if (args.IsPostBack)
        {
            // Get information from args
        }
        else
        {
            SheerResponse.ShowModalDialog("/QuickContact.html",true);
            args.WaitForPostBack();
        }
    }
    }
}

This is the html for the modaldialog: 这是模态对话框的html:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base target="_self">
<title></title>
<script type="text/javascript">
    function sendResponse() {
        var o = new Object();
        o.forename = document.getElementById("FirstNameId").value;
        o.surname = document.getElementById("LastNameId").value;
        o.phone = document.getElementById("PhoneId").value;
        window.returnValue = o;
    }

    function OK() {
        sendResponse();
        window.close();
        self.close();
        document.close();
    }
</script>
</head>
<body onbeforeunload="sendResponse()">
<label>First Name: </label><input type="text" id="FirstNameId" /><br />
<label>Last Name: </label><input type="text" id="LastNameId" /><br />
<label>Phone: </label><input type="text" id="PhoneId" /><br />
<a href="#" id="btnSaveImage" target="_self" onclick="OK()">
    OK
</a><br />
<input type="button" value="OK" onclick="OK()" />

What i want is for the user to fill in a couple of fields. 我想要的是用户填写几个字段。 When the users clicks on OK the values are returned and the window is closed. 当用户单击“确定”时,将返回值并关闭窗口。 All i am missing is the automatic close of the dialog screen. 我所缺少的只是对话框屏幕的自动关闭。

I've tried pretty much everything i could find on the web but still it doesn't work. 我已经尝试了几乎可以在网上找到的所有内容,但仍然无法正常工作。

Does anyone know what else i can try ? 有谁知道我还能尝试什么?

I found a way to close the Modal dialog created by Sheerresponse: 我找到了一种关闭由Sheerresponse创建的“模态”对话框的方法:

window.parent.$('.ui-dialog-content:visible').dialog('close'); 。window.parent $( 'UI的对话内容:可见 ')。对话框(' 亲密');

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

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