In SP2010 you could easily show a dialog using a DOM node with something like this:

var test = "<div id='correspondence'>" + result + "</div>";

            html: document.getElementById('correspondence'),
            title: "Correspondence",
            allowMaximize: false,
            showClose: true,
            autoSize: true

In SP 2013 I cannot for the life of me get this working. All that I get is an error stating: SyntaxError: missing ) after argument list. Below is the code I tried. Any ideas on how to get this working?

SP.SOD.executeFunc('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', function() 
    var dlgOptions = { html:document.getElementById('correspondence'), autoSize: true, autoSizeStartWidth: 550 };  

In the first code snippet you have doubled the ' around getElementById.

In the second code snippet you have forgotten the html: in front of getElementById

Edit after James comment: If you are not using minimal download strategy, you do not have to use SOD.

  • 1
    You need SOD when you have minimal download strategy turned on.
    – James
    Aug 8 '13 at 21:24

As Robert has said there are issues with the JavaScript.

However, I had problems as well and had to add the following code to the base of my page to load the appropriate SharePoint scripts. The Initialise Page is a JavaScript function which sets up the page.

ExecuteOrDelayUntilScriptLoaded(ITSP.TaskForm.InitialisePage, "sp.ui.dialog.js");
SP.SOD.executeFunc("sp.js", "SP.ClientContext", function(){});
  • It says ITSP.TaskForm.InitialisePage is undefined when I run that code. Where did you get that from?
    – James
    Aug 8 '13 at 21:19
  • Sorry this is just a javascript function which is called when the sp.ui.dialog.js is loaded. I use a function to initialise the page and setup various elements on the page. You could wrap your dialog code inside a function and then reference the replace ITSP.TaskForm.InitialisePage with your function.
    – Simon Doy
    Aug 8 '13 at 22:13

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .