In my master page, I have attached jQuery along with my own custom.js. I use the javascript in that file to run fixes on my pages such as style adjustments.
Now, when I run simple functions on my sharepoint pages, they never run on the outputted markup unless I use _spBodyOnLoadFunctionNames.push
on the function. Alerts WILL fire, however. So, I tried using jquery's document.ready
instead, but it NEVER fires. Neither does ExecuteOrDelayUntilScriptLoaded
ever fire.
For example, if I put this in my custom.js file:
$(document).ready(function(){
alert("bob");
});
It never fires. But if I just put
alert("bob");
It will fire just fine.
However, if I use _spBodyOnLoadFunctionNames.push
to run my jquery functions, they DO work, so it isn't that jquery isn't getting loaded.
Am I missing something? Why won't document.ready work?
_spBodyOnLoadFunctionNames
instead ofdocument.ready
? Apart from that, here's an article describing the reason of using document.ready or the sharepoint onload-function: stephanrocks.com/2011/10/05/… hope it helps. – Dominik Dec 17 '12 at 8:56