I was able to insert my dialog. But I'm not able to display it.
This is how I insert it:
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>");
}
And this is how I try to display it:
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");
}
}
]
});
But when I run my code, it doesn't display the dialog. Additionally i'm trying to find a way to get the response from the textbox.
Can anyone help me?
Also see : JQuery dialog as input
In my js-file I also have to following line:
answer = GetEmailBody();
End the GetEmailBody() calls the method you see higher up to display the dialog.
My code now looks as follows:
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);
}
But now I get a message that an app should be opened on my computer. This was not necessary when I didn't go through the dialog. Then it called my ASHX-file which did the sending of the mail.
autoOpento true? Demo