SharePoint 2013 add javascript after whole page load

前端 未结 5 886
死守一世寂寞
死守一世寂寞 2020-12-12 20:06

Disclaimer: I have no experience with SharePoint2013.

I have problem - I must include/fire some javascript functions after the whole page has been loaded. I tried li

5条回答
  •  星月不相逢
    2020-12-12 21:00

    https://mhusseini.wordpress.com/2012/05/18/handle-clicks-on-calendar-items-in-sharepoint-2010-with-javascript/

    The above link worked for me. He basically uses the ExecuteOrDelayUntilScriptLoaded to launch his calendar hook code after the SP.UI.ApplicationPages.Calendar.js loads.

    Then, in the calendar hook he attaches his own function to the: SP.UI.ApplicationPages.CalendarStateHandler.prototype.onItemsSucceed function.

     _spBodyOnLoadFunctionNames.push("LaunchColorCodeCalendarScriptOnReady");
    
    
    function LaunchColorCodeCalendarScriptOnReady() {
    
    
        ExecuteOrDelayUntilScriptLoaded(
            MyCalendarHook,
            "SP.UI.ApplicationPages.Calendar.js");
    
    
    }
    
    function MyCalendarHook() {
        var _patchCalendar = function () {
            //Do something to the items in the calendar here
            //ColorCodeCalendar();
        };
    
        var _onItemsSucceed = SP.UI.ApplicationPages.CalendarStateHandler.prototype.onItemsSucceed;
        SP.UI.ApplicationPages.CalendarStateHandler.prototype.onItemsSucceed = function ($p0, $p1) {
            _onItemsSucceed.call(this, $p0, $p1);
            _patchCalendar();
        };
    }
    

提交回复
热议问题