Delay/Call On Page Edit initialization from Javascript

Vote:
 

Hi!
I'm looking for a way to tell the on page editing initialization to wait a minute until I'm done with rendering the page. Some of our pages make Ajax requests for content, and when that content comes in the on page editing is already initialized and it's not possible to edit the new content.

Is there any API I can use to tell EPiServer to wait, or to look again for new editable content?

Another option would be if someone could tell me what event EPiServer (dojo) listens to to start the initilization so that I could override it and trigger it manually when I'm done. Is it the "load" event on the iframe?

#140291
Oct 15, 2015 8:57
Vote:
 

http://world.episerver.com/documentation/Javascript-Library/?documentId=CMS/9/epi-cms/_ContentContextMixin

Try
contentContextChanged ( ctx , callerData )

Regards
/K

#140305
Oct 15, 2015 15:32
Vote:
 

You can also try subscribing to the "/epi/shell/context/current" topic. This is broadcast when the current context has changed so will fire each time the editor selects some new content. I use this as part of the MenuPin initialisation so you may find some inspiration from the implementation: https://github.com/davidknipe/MenuPin/blob/master/MenuPin/ClientResources/Scripts/MenuPin/MenuPinInit.js

#140320
Oct 15, 2015 21:41
Vote:
 

Thanks a lot for the suggestions! Here's where I've gotten so far:

window.parent.require(["epi-cms/_ContentContextMixin"],
    function (contentContextMixin) {
        var widget = window.parent.dojo.declare([contentContextMixin], {
            initialize: function () {
                this.inherited(arguments);

                var self = this;
                window.parent.triggerRef = function() {
                    console.log(self.contentContextChanged());
                };
            }
        });
        new widget().initialize();
    }
);

When I invoke something in the preview iframe that loads new content with Ajax (and the content shows up correctly, but the block controls from EPiServers UI are missing) i run "triggerRef()" manually in DevTools. But nothing seems to happen. I'm sure I'm doing something wrong here, could anyone point me in the right direction?

#140331
Oct 16, 2015 8:25
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.