如标题所述,我尝试从另一个文件调用 $(document).ready(function() {...});。 代码片段如下:
源文件:
源文件:
$(document).ready(function () {
alert('document.ready function called!');
// a lot of code
}
在测试文件中:
TestFile.prototype.testDocumentReadyContents = function () {
// test code here trying to call the document.ready function
}
我还没有在这方面取得任何成功。我已经尝试过document.ready.apply(),trigger('ready'),覆盖document.ready函数...但是就是不能调用它。顺便说一下,我是在我的单元测试中调用它的。
谢谢。