1

I'm working with SharePoint modal dialogs but I have some problem making the call work. When I call the OpenPopUpPage (or OpenPopUpPageWithTitle) methods I'm getting the following errors

Chrome: Cannot read property 'defaultDialogWidth' of undefined

Firefox: SP.Res is undefined

It would seem that part of the scripts are failing loading or missing. What are the scripts that I should load to show dialog (except sp.ui.dialog.js)?

  • This occurred because, I've loaded sharepoint javascript files directly using script tags which caused some of the ashx files and namespaces failed to load on the page, I removed manually added script tags and used sharepoint on demand script functions.It solved the issue, I referred the sp.js inside one of my search control template which caused the issue. It also solved an issue says "The property or Field not initialized" even when I put Include parameter in my ctx.load() function. – sekhar Jan 12 '17 at 10:21
1

Based on the error reported by Firefox, I suppose that your method is failing because the "SP.js" script file is "lazy loaded" and thus not fully loaded when your logic executes.

If this is the case, you need to delay the execution of your function until the script has been loaded. You can do this by using the ExecuteOrDelayUntilScriptLoaded function.

 ExecuteOrDelayUntilScriptLoaded(SomeFuction, "SP.js")

In the above example "SomeFunction" is the actual function that will execute the open dialog logic.

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.