1

I open popup modal dialog with something like this:

openInDialog: function (dlgWidth, dlgHeight, dlgAllowMaximize, dlgShowClose, needCallbackFunction, pageUrl) {
    var options = {
        autoSize: true,
        url: pageUrl, width: dlgWidth, height: dlgHeight, allowMaximize: dlgAllowMaximize,
        showClose: dlgShowClose
    };

if (needCallbackFunction) {
    options.dialogReturnValueCallback = Function.createDelegate(null, se_scripts.CloseDialogCallback);
}
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);

}

And I want simply change title of this dialog when it's opened.

From this "List Name - Title" to this "List". Because my title has a strange system name. I have something like "List Name - WeirdoSystemTitle", so I don't want to scare users with this.

I use something like this:

var oldText= parent.document.getElementById("dialogTitleSpan");
var newText=oldText.textContent.split("-")[0];
SP.UI.UIUtility.setInnerText(parent.document.getElementById("dialogTitleSpan"), newText); 

It works like a charm. But how to indicate when dialog is opened?

$(document).ready(changeTitle())

and

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', changeTitle );

doesn't work.

Please help ^)

1

Add the title to your options:

openInDialog: function (dlgWidth, dlgHeight, dlgAllowMaximize, dlgShowClose, needCallbackFunction, pageUrl) {
        var options = {
            autoSize: true,
            title: "List",
            url: pageUrl, width: dlgWidth, height: dlgHeight, allowMaximize: dlgAllowMaximize,
            showClose: dlgShowClose
        };

    if (needCallbackFunction) {
        options.dialogReturnValueCallback = Function.createDelegate(null, se_scripts.CloseDialogCallback);
    }
    SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
  • that's exactly what I did as workaround. ^_^ but in that case I need to use jsom\csom for getting list name and then putting it as title in options. what do you think there's no easy way? I try to avoid requests to the server for better performance... – Sergey Zykov Mar 28 '16 at 15:23
  • You don't have the list title at runtime? How else are you getting the pageUrl? You could add your change title function to the view/edit form and query the url for IsDlg=1 – Erin L Mar 28 '16 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.