我能夠插入我的對話框。但我無法顯示它。使用JS文件顯示JQuery對話框
這是我如何插入:
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文件。
您需要將事件綁定到該事件。 –
我認爲沒有真正的事件。 我在SharePoint中做它。在那裏點擊一個按鈕,我需要發送一封電子郵件。該對話框在那裏,用戶可以輸入附加信息添加到電子郵件中。 –
如何將'autoOpen'設置爲true? [演示](https://jsfiddle.net/catsjwzy/1/) – empiric