While working with SharePoint / JavaScript modal pop up you might encounter error "cannot read property 'showmodaldialog' of undefined". Here is simple solution for that.
Code Sample:
function OpenDocsDialog(url1) {
var options = {
url: url1,
dialogReturnValueCallback: myDialogCallback
};
SP.UI.ModalDialog.showModalDialog(options); // this line gives error.
}
Solution : We need to load "sp.js" file before calling above code. You can load "sp.js" file with below code sample:
ExecuteOrDelayUntilScriptLoaded(function () { //code }, "sp.js")
Full solutionExample :
function OpenDocsDialog(url1) {
var options = {
url: url1,
dialogReturnValueCallback: myDialogCallback
};
ExecuteOrDelayUntilScriptLoaded(function () {
SP.UI.ModalDialog.showModalDialog(options);
}, "sp.js")
}
Subscribe to:
Post Comments (Atom)
-
Issue : Recently, we had a requirement to sync the calendar between shared mailbox outlook and SharePoint Calendar list. We have created 2 f...
-
Issue : Recently there was an issue we face while training React. Generally we give training using video series on YouTube but this time we ...
-
Issue: Recently, we were developing a SPFx webpart in which we needed to open a dialog. For that we decide to use Office Fabric UI Dialog co...
No comments:
Post a Comment