Search code examples
javascriptdom-eventssharepoint-2013

SharePoint 2013 - How to execute JavaScript on postback


I am trying to execute JavaScript on the client after each postback from an InfoPath browser enabled form. This worked until we recently upgraded to SharePoint 2013. Does anyone know if there are any events to which I could attach a handler to achieve this?


Solution

  • After a lot of pain I eventually found a solution to this, albeit there is an explicit 15ms delay after each postback. The View.PostCreate function within the InfoPath Form Services JavaScript is called after the render phase of every postback.

    ExecuteOrDelayUntilScriptLoaded(function () {
        var viewPostCreateBase = View.PostCreate;
        var viewPostCreateOverride = (function (a) {
    
            return function (a) {
                viewPostCreateBase(a);
                // Code to be executed after each postback
            }
        });
        View.PostCreate = viewPostCreateOverride();
    
    }, "_InfoPathCoreJs");