[英]Calling $(document).ready(function() {…}); from another file
如標題所示,我試圖調用$(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函數...但無法調用它。 僅供參考,我正在將其作為單元測試的一部分進行調用。
謝謝。
$(document).ready(documentReady);
function documentReady() {
alert('document.ready function called!');
// a lot of code
}
TestFile.prototype.testDocumentReadyContents = function () {
documentReady();
}
TestFile.prototype.testDocumentReadyContents = function () {
$.readyList[0]();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.