0

I'm working on SharePoint server 2010. I have added a webpart, which is a simple HTML document. This document is loaded into an iframe and is rendered into the main screen.

I would like to use the exposed SP object and retrieve information about user and his permissions, but seems that this is not possible for some reason. Part of my code is:

            ..... init: function () {
            this.context = new SP.ClientContext.get_current();
            this.web = this.context.get_web();
            this.spGroups = this.web.get_siteGroups();
            this.currentUser = this.web.get_currentUser();

            this.context.load(this.currentUser);
            this.context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod), Function.createDelegate(this, this.onFailureMethod));

            this.bindEvents();
         }, .....

At the end of the file I have this:

        $(document).ready(function () {
           window.SP = window.parent.SP;
           rvtViewModel.init();
        });

SP object is passed and is present, but SP.ClientContext returns always undefined.

Is there a way to use the SP.ClientContext object from within an iframe? If yes some short explaination/code would be highly appreciated.

Regards

1 Answer 1

0

Try _spBodyOnLoadFunctionNames instead of document.ready

 _spBodyOnLoadFunctionNames.push("SharePointReady");

 function SharePointReady() {
    window.SP = window.parent.SP;
    rvtViewModel.init();
 }

Also I believe the above init should get invoked from the Parent - Because only Parent know when SharePoint files has loaded completely.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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