SheerResponse没有关闭
本文关键字:SheerResponse | 更新日期: 2023-09-27 18:16:56
这是Sitecore 8 Update 2 MVC网站的一部分,我正在扩展TreelistEx字段
我已经创建了一个纯响应模式对话框,由下面的代码调用。
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();
}
}
}
}
这是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()" />
我想让用户填写几个字段。当用户单击OK时,返回值并关闭窗口。我所缺少的是对话框屏幕的自动关闭。
我已经尝试了几乎所有我能在网上找到的,但它仍然不起作用。
有谁知道我还可以尝试什么吗?
我找到了一种方法来关闭由Sheerresponse创建的模态对话框:
window.parent。$ (' .ui-dialog-content:可见').dialog("关闭");