使用 JS 文件显示 JQuery 对话框
Display JQuery dialog using a JS-file
我能够插入我的对话框。但是我无法显示它。
我是这样插入的:
if ($("#dialogSendMail").length) {
}
else {
$("#DeltaPlaceHolderUtilityContent").after("<div id='dialogSendMail' title='Enter mail body'> <label for='mailBody'>Type the text you want to display in the email:</label><p><input type='text' id='mailBody' name='mailBody'></p></div>");
}
这就是我尝试显示它的方式:
var answer ="";
$( "#dialogSendMail" ).dialog({
resizable: false,
height:350,
width:650,
modal: true,
autoOpen : false,
buttons: [
{
text: "Send Mail",
click: $.noop,
type: "submit",
form: "myForm"
},
{
text: "Close",
click: function () {
$(this).dialog("close");
}
}
]
});
但是当我 运行 我的代码时,它不显示对话框。此外,我正在尝试找到一种从文本框获取响应的方法。
谁能帮帮我?
另见:
在我的 js 文件中,我还必须添加以下行:
answer = GetEmailBody();
结束 GetEmailBody() 调用您在上方看到的方法以显示对话框。
我的代码现在如下所示:
function GetEmailBody() {
$("#dialogSendMail").dialog({
resizable: false,
height: 350,
width: 650,
modal: true,
autoOpen: true,
buttons: [
{
text: "Send Mail",
click: function () {
$(this).dialog("close");
answer = "This is just a test message.";
SendEmail();
}
},
{
text: "Close",
click: function () {
$(this).dialog("close");
SendEmail();
}
}
]
});
}
function SendEmail()
{
xmlHttpReq.open("GET", _spPageContextInfo.siteServerRelativeUrl + "/_layouts/SendDocuments/MyCustomHandler.ashx?ItemsArray=" + fileRefArray + "&IdsArray=" + idArray + "&EmailText=" + answer, false);
xmlHttpReq.send(null);
var yourJSString = xmlHttpReq.responseText;
alert(yourJSString);
}
但现在我收到一条消息,提示应在我的计算机上打开一个应用程序。
当我没有通过对话时,这是没有必要的。
然后它调用我的 ASHX 文件来发送邮件。
将自动打开设置为真:
$( "#dialogSendMail" ).dialog({
resizable: false,
height:350,
width:650,
modal: true,
autoOpen : true,
buttons: [
{
text: "Send Mail",
click: $.noop,
type: "submit",
form: "myForm"
},
{
text: "Close",
click: function () {
$(this).dialog("close");
}
}
]
});
好的,我能够解决我的问题:
函数 GetEmailBody() {
$("#dialogSendMail").dialog({
可调整大小:假,
身高:350,
宽度:650,
模态:真,
自动打开:真,
纽扣: [
{
文本:"Send Mail",
点击:功能(){
$(this).dialog("close");
answer = $(mailBody)[0].innerText;
xmlHttpReq.open("GET", _spPageContextInfo.siteServerRelativeUrl + "/_layouts/SendDocuments/MyCustomHandler.ashx?ItemsArray=" + fileRefArray + "&IdsArray=" + idArray + "&EmailText=" + answer,错误的);
xmlHttpReq.send(空);
var yourJSString = xmlHttpReq.responseText;
alert(yourJSString);
}
},
{
text: "Close",
click: function () {
$(this).dialog("close");
SendEmail();
}
}
]
});
}
function SendEmail()
{
xmlHttpReq.open("GET", _spPageContextInfo.siteServerRelativeUrl + "/_layouts/SendDocuments/MyCustomHandler.ashx?ItemsArray=" + fileRefArray + "&IdsArray=" + idArray + "&EmailText=" + answer, false);
xmlHttpReq.send(null);
var yourJSString = xmlHttpReq.responseText;
alert(yourJSString);
}
这如我所愿。
我能够插入我的对话框。但是我无法显示它。
我是这样插入的:
if ($("#dialogSendMail").length) {
}
else {
$("#DeltaPlaceHolderUtilityContent").after("<div id='dialogSendMail' title='Enter mail body'> <label for='mailBody'>Type the text you want to display in the email:</label><p><input type='text' id='mailBody' name='mailBody'></p></div>");
}
这就是我尝试显示它的方式:
var answer ="";
$( "#dialogSendMail" ).dialog({
resizable: false,
height:350,
width:650,
modal: true,
autoOpen : false,
buttons: [
{
text: "Send Mail",
click: $.noop,
type: "submit",
form: "myForm"
},
{
text: "Close",
click: function () {
$(this).dialog("close");
}
}
]
});
但是当我 运行 我的代码时,它不显示对话框。此外,我正在尝试找到一种从文本框获取响应的方法。
谁能帮帮我?
另见:
在我的 js 文件中,我还必须添加以下行:
answer = GetEmailBody();
结束 GetEmailBody() 调用您在上方看到的方法以显示对话框。
我的代码现在如下所示:
function GetEmailBody() {
$("#dialogSendMail").dialog({
resizable: false,
height: 350,
width: 650,
modal: true,
autoOpen: true,
buttons: [
{
text: "Send Mail",
click: function () {
$(this).dialog("close");
answer = "This is just a test message.";
SendEmail();
}
},
{
text: "Close",
click: function () {
$(this).dialog("close");
SendEmail();
}
}
]
});
}
function SendEmail()
{
xmlHttpReq.open("GET", _spPageContextInfo.siteServerRelativeUrl + "/_layouts/SendDocuments/MyCustomHandler.ashx?ItemsArray=" + fileRefArray + "&IdsArray=" + idArray + "&EmailText=" + answer, false);
xmlHttpReq.send(null);
var yourJSString = xmlHttpReq.responseText;
alert(yourJSString);
}
但现在我收到一条消息,提示应在我的计算机上打开一个应用程序。 当我没有通过对话时,这是没有必要的。 然后它调用我的 ASHX 文件来发送邮件。
将自动打开设置为真:
$( "#dialogSendMail" ).dialog({
resizable: false,
height:350,
width:650,
modal: true,
autoOpen : true,
buttons: [
{
text: "Send Mail",
click: $.noop,
type: "submit",
form: "myForm"
},
{
text: "Close",
click: function () {
$(this).dialog("close");
}
}
]
});
好的,我能够解决我的问题:
函数 GetEmailBody() { $("#dialogSendMail").dialog({ 可调整大小:假, 身高:350, 宽度:650, 模态:真, 自动打开:真, 纽扣: [ { 文本:"Send Mail", 点击:功能(){ $(this).dialog("close"); answer = $(mailBody)[0].innerText; xmlHttpReq.open("GET", _spPageContextInfo.siteServerRelativeUrl + "/_layouts/SendDocuments/MyCustomHandler.ashx?ItemsArray=" + fileRefArray + "&IdsArray=" + idArray + "&EmailText=" + answer,错误的); xmlHttpReq.send(空);
var yourJSString = xmlHttpReq.responseText;
alert(yourJSString);
}
},
{
text: "Close",
click: function () {
$(this).dialog("close");
SendEmail();
}
}
]
});
}
function SendEmail()
{
xmlHttpReq.open("GET", _spPageContextInfo.siteServerRelativeUrl + "/_layouts/SendDocuments/MyCustomHandler.ashx?ItemsArray=" + fileRefArray + "&IdsArray=" + idArray + "&EmailText=" + answer, false);
xmlHttpReq.send(null);
var yourJSString = xmlHttpReq.responseText;
alert(yourJSString);
}
这如我所愿。