Skip to content Skip to sidebar Skip to footer

Calling $(document).ready(function() {...}); From Another File

As the title suggested, I'm trying to call the $(document).ready(function() {...}); from another file. The code snippet is as below: Source file: $(document).ready(function () {

Solution 1:

GOOD WAY

$(document).ready(documentReady);

function documentReady() {
    alert('document.ready function called!');
    // a lot of code
}

TestFile.prototype.testDocumentReadyContents = function () {
    documentReady();
}

Hackish Way

TestFile.prototype.testDocumentReadyContents = function () {
    $.readyList[0]();
}

Post a Comment for "Calling $(document).ready(function() {...}); From Another File"