Issue with javascript / jquery not firing on a SharePoint 2013 page or masterpage?

May 19th, 2014 | Posted by Marijn in code | customization | fix | jquery / javascript

I just spend a few hours analyzing why my Javascript/jQuery was not firing on my masterpage. Everything was good, I was down to using the simplest of code:

_spBodyOnLoadFunctions.push(function() { alert(“test”); });

No pop-up. It was in my source code. No script errors. Nothing. Silent. Dead.
Was there something wrong? Should I use document.ready ? Ofcourse not.

Once again, Elio Struyf came to the rescue. He asked me if the “Minimal Download Strategy” feature was enabled. Yes it was, I replied with a frown.

Apparantly, when you put scripts in your masterpage with the MDS feature enabled, things go horribly wrong. So, turn it off and see your javascript or jQuery running on the page!

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

Leave a Reply

%d bloggers like this: