Modal Dialog With Custom Code.
<script type="text/javascript" >
ShowNewFolderModalPopUp();
function ShowNewFolderModalPopUp()
{
var options = SP.UI.$create_DialogOptions();
options.title = "Enter folder name";
options.autosize = true;
options.html = createFolderDialogElement();
options.showClose= true;
options.allowMaximize = false;
options.dialogReturnValueCallback = FolderNewCallback;
SP.UI.ModalDialog.showModalDialog(options);
}
function createFolderDialogElement() {
var dialogElement = jQuery(jQuery('#DialogMarkup').html());
dialogElement.find('#cancelButton').on('click', function() {
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, jQuery('#FolderNameTextBox').val());
});
dialogElement.find('#SubmitButton').on('click', function() {
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, jQuery('#FolderNameTextBox').val());
});
return dialogElement.get(0);
}
function FolderNewCallback(dialogResult, returnValue) {
if(dialogResult == SP.UI.DialogResult.OK && returnValue) {
if(returnValue != '')
{
SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
}
}
if(dialogResult == SP.UI.DialogResult.cancel) {
}
}
</script>
<script type="text/html" id="DialogMarkup">
<div>
<label for="FolderNameTextBox">Enter Folder Name :</label>
<input type="text" id="FolderNameTextBox"/><br><br>
<input type="button" id="SubmitButton" value="Submit"/>
<input type="button" id="cancelButton" value="Cancel"/>
</div>
</script>
No comments:
Post a Comment