0

On the start page of a Sharepoint 2013 Intranet portal I put a search result webpart. The webpart is styled and formatted into a slider with jQuery & CSS

For some reason sometimes the jQuery on search result webparts is not triggered. This only occurs after an iisreset or when there's a delay for some other reason. After refreshing the page the slider loads without any problem.

I've tried several solution (_spBodyOnLoadFunctionNames, SP.SOD.execeuteFunc, executeOrDalayUntilScriptLoaded), but none of them seems to work. My current code looks like:

function PageLoadTrigger() {
   // initiate slider
}
_spBodyOnLoadFunctionNames.push("PageLoadTrigger");

It only seems to happen on search result webparts. All other jQyery runs fine.

Is anyone aware of this problem and is there a solution?

2 Answers 2

0

not sure if it is a js script file that is not running but I had a same sort of problem with sp.js file (SP.ClientContext was not working). Solved it with this:

$("document").ready(function () {

    var scriptbase = _spPageContextInfo.webAbsoluteUrl + "/_layouts/15/";
    $.getScript(scriptbase + "sp.js", function () {
        //rest of my code
    });

});

replace the first argument of getScript for the URL of your script file.

0

Thanks, you pointed me in the right direction. I only added the no conflict option.

var j = jQuery.noConflict();
j(document).ready(function () {

    jRoot = _spPageContextInfo.webAbsoluteUrl;
    j.getScript(jRoot + "/_layouts/15/SP.js", function () {
        PageLoadTrigger();
    });
});

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.