簡體   English   中英

SheerResponse沒有關閉

[英]SheerResponse doesn't close

這是Sitecore 8 Update 2 MVC網站的一部分,我在擴展TreelistEx字段

我創建了一個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();
        }
    }
    }
}

這是模態對話框的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()" />

我想要的是用戶填寫幾個字段。 當用戶單擊“確定”時,將返回值並關閉窗口。 我所缺少的只是對話框屏幕的自動關閉。

我已經嘗試了幾乎可以在網上找到的所有內容,但仍然無法正常工作。

有誰知道我還能嘗試什么?

我找到了一種關閉由Sheerresponse創建的“模態”對話框的方法:

。window.parent $( 'UI的對話內容:可見 ')。對話框(' 親密');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM