Jul 5, 2013

Delaying javascript execution

Delaying execution of javascript until certain condition is fulfilled :

    function WaitForAnsycPostback(cb) {
        var requestManager = Sys.WebForms.PageRequestManager.getInstance();
        if (requestManager.get_isInAsyncPostBack()) {
            setTimeout(function () {
                WaitForAnsycPostback(cb);
            }, 250);
        }
        else {
            if (typeof(cb) == 'function') cb();
        }
    }

No comments:

Post a Comment