Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I got "Type is undefined" and "SP is undefined" message when I try to open the list form in sharepoint modal dialog. Could anyone help me to resolve this issue?

This is the code:

<script type="text/javascript" language="javascript" src="/_layouts/SPP.ContentDesigner/Scripts/SP.UI.Dialog.js"></script>     
<script type="text/javascript">


     //Handle the DialogCallback callback 
          function DialogCallback(dialogResult, returnValue){ 
          } 

 //Open the Dialog 
          function OpenEditDialog(id) {
              debugger;
       var options = { 
         url:"http://devcd/Lists/NewTest/EditForm.aspx?ID=1&IsDlg=1", 
         width: 700, 
         height: 700, 
         dialogReturnValueCallback: DialogCallback 
         }; 
        SP.UI.ModalDialog.showModalDialog(options); 
      }
      </script>
share|improve this question
In which context this js code run? web part page, or application page, or other? – Kai Dec 21 '11 at 17:37
refer answer from this, it may be helpful. – Kai Dec 21 '11 at 17:43
i got this error in sharepoint application page, my actual requirement is it should work on all type of pages(webpart page, application page, publishing page). could you guide me please? – Rasu Dec 22 '11 at 6:09
Hm, it works on application page for me, why do you include this script - src="/_layouts/SPP.ContentDesigner/Scripts/SP.UI.Dialog.js"? Try to rename it, may be some conflicts with standard file occure. – Kai Dec 22 '11 at 8:23
if i comment this line itself i got the same issue, do you have any idea? – Rasu Dec 22 '11 at 14:10

2 Answers

SP.js uses "lazy load". Invoke your function inside ExecuteOrDelayUntilScriptLoaded:

ExecuteOrDelayUntilScriptLoaded(OpenEditDialog, "SP.js")
share|improve this answer

I battled with this for a good while - in my case changing "LoadAfterUI" attribute in the ScriptLink to "true" fixed it where nothing else worked.

share|improve this answer
1  
As you can see in the question, the scripts are not loaded with the ScriptLink control, so this does not really apply – Robert Lindgren May 17 at 13:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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