Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

Showing a modal pop-up (dialog box) in parent window from an app part

$
0
0

I have developed a Sharepoint 2013 provider hosted app that includes some app parts. I want to be able to show a modal pop-up (dialog box) on the parent sharepoint site by clicking a button/link in my app part. I have read about the "showModalDialog" method in Sharepoint  2010 but I cannot get this to work.

I have also been experimenting with trying to call jquery dialog boxes in the parent window from the app part as well but I cannot get this to work either. 

Can anyone give me any advice as to how I could get something like this working?

The code I tried so far in my app part is as follows but it is throwing the following error "TypeError: Object doesn't support property or method '$create_DialogOptions'"

    var hostweburl;

        // Load the required SharePoint libraries.
        $(document).ready(function () {

            // Get the URI decoded URLs.
            hostweburl =
                decodeURIComponent(
                    getQueryStringParameter("SPHostUrl")
            );

            // The js files are in a URL in the form:
            // web_url/_layouts/15/resource_file
            var scriptbase = hostweburl + "/_layouts/15/";

            // Load the js files and continue to
            // the execOperation function.
            $.getScript(scriptbase + "SP.Runtime.js",
                function () {
                    $.getScript(scriptbase + "SP.js", execOperation);
                }
            );
        });

        // Function to execute basic operations.
        function execOperation() {

            try{

                options = SP.UI.$create_DialogOptions();

                options.width = width;
                options.height = height;
                options.url = url;
                options.allowMaximize = true;
                options.showClose = close;
                options.dialogReturnValueCallback = Function.createDelegate(1, CloseCallback);
                SP.UI.ModalDialog.showModalDialog();

            }
            catch(err){
                alert("error:" + err)
            }
        }

        // Function to retrieve a query string value.
        // For production purposes you may want to use
        // a library to handle the query string.
        function getQueryStringParameter(paramToRetrieve) {
            var params =
                document.URL.split("?")[1].split("&");
            var strParams = "";
            for (var i = 0; i < params.length; i = i + 1) {
                var singleParam = params[i].split("=");
                if (singleParam[0] == paramToRetrieve)
                    return singleParam[1];
            }
        }


Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>