将 $(document).ready 包装在 $(window).load 中?
Wrapping $(document).ready inside $(window).load?
根据答案 here,我需要将所有代码包装在 $(window).load(function(){
中。但是,我的图库还使用 imagesLoaded(在图像准备就绪时加载图像)和 ajax 在单击按钮时加载更多项目。我现在的布局是这样的:
function initialise(){
//code goes here, including imagesLoaded
};
$(document).ready(function(){
initialise();
});
$(document).ajaxComplete(function () {
initialise();
//ajax code goes here
});
如何将所有这些都包装在 $(window).load(function () {
中?
就这样吧!
$(window).load(function () {
function initialise(){
//code goes here, including imagesLoaded
};
$(document).ready(function(){
initialise();
});
$(document).ajaxComplete(function () {
initialise();
//ajax code goes here
});
});
根据答案 here,我需要将所有代码包装在 $(window).load(function(){
中。但是,我的图库还使用 imagesLoaded(在图像准备就绪时加载图像)和 ajax 在单击按钮时加载更多项目。我现在的布局是这样的:
function initialise(){
//code goes here, including imagesLoaded
};
$(document).ready(function(){
initialise();
});
$(document).ajaxComplete(function () {
initialise();
//ajax code goes here
});
如何将所有这些都包装在 $(window).load(function () {
中?
就这样吧!
$(window).load(function () {
function initialise(){
//code goes here, including imagesLoaded
};
$(document).ready(function(){
initialise();
});
$(document).ajaxComplete(function () {
initialise();
//ajax code goes here
});
});