Wednesday, 28 May 2014

Sharepoint - Object # has no method 'showModalDialog' in chrome

 Consider the following code:
function ShowWelcomeDialog() {
    var data = {};

    var options = {
        url: "/_layouts/xxxx/xxxxxss.aspx",
        title: "xxx xxx",
        width: 700,
        height: 950,
        dialogReturnValueCallback: myDialogCallback,
        args: JSON.stringify(data)
    };

    SP.UI.ModalDialog.showModalDialog(options);
    return false;
}
 I have this code for a button click and the modal opens fine in firefox and ie. But it doesn't open in Chrome. It gives the following error in console:
Uncaught TypeError:Object # has no method 'showModalDialog'..
 Solution:

Replace the line:
SP.UI.ModalDialog.showModalDialog(options);
with
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);



StackOverFlow