1

Using jquery I'm opening a SharePoint page in a dialog, this works perfectly fine. Now on that page I have a button to submit a custom form and finally close the dialog again. While this works when looking in the console it throws two errors.

Is this something to worry about? And perhaps more importantly, how do I get rid of them?

Here's the code to open the dialog:

SP.UI.ModalDialog.showModalDialog(   
                    {  
                        url: _spPageContextInfo.siteAbsoluteUrl + "/SitePages/Checklist.aspx?Phase=" + newProjectPhase + "&Type=" + newProjectType + "&ProjectId=" + projectId,
                        title: "Checkliste ved skift af projektfase",
                        height: 250,
                        dialogReturnValueCallback: function(result){
                            if (result == SP.UI.DialogResult.OK) {
                                //alert("Closed succesfully");
                                originalSaveButtonClickHandler();
                            }
                            if (result == SP.UI.DialogResult.cancel) {
                                //alert("Cancelled...");
                            }
                        }
                    }

And the code to close the close the dialog again (Placed on new dialog page):

window.frameElement.commonModalDialogClose(1, 'Closed with OK result'); return false;

The error thrown is here: enter image description here

The first message is quite straight forward, somewhere 'now' cannot be referenced. The second one roughtly translates to "An object was expected".

Any ideas? The main problem right now, is the fact that IE sometimes opens a popup regarding the error - and Id rather not have my end users being bothers by that.

  • Hi, Morten k i have apply above code in my console it works perfect without any error. so make sure your all dependency files load properly. – Bhavik Shingala Nov 2 '18 at 5:16
  • Thanks for your feedback. How can I make sure that's the case? For instance when I close the dialog on the default X in the right corner no errors are shown. – Morten K Nov 2 '18 at 6:00

Your Answer

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

Browse other questions tagged or ask your own question.