0
내가 주요 내용을로드 Ajax를 사용하여 사이트를 가지고 있고, 나는 .load()
이 완료된 후 함수 (afterLoad
)를 실행하려면 다음 코드를 사용하고 완료 ..지연 기능은
jQuery('.main-menu a').click(function(evt){
var href = jQuery(this).attr('href');
var elementClassName = jQuery(this).attr('class');
History.pushState({}, '', href);
jQuery('.content').load(href+ ' #main',afterLoad);
function afterLoad() {
jQuery('.content').fadeIn(750);
if (document.location.pathname == "/works/") {
jQuery(function($){ window.dzsp_init("#port0",{
settings_slideshowTime:3
,settings_mode: "masonry"
,title: ""
,design_item_width: ""
,design_item_height: ""
,design_categories_style: "normal"
,design_categories_pos: "top"
,design_pageContent_pos: "top"
,settings_disableCats: "off"
,settings_lightboxlibrary: "zoombox"
,settings_preloadall: "off"
,audioplayer_swflocation: "http://sbmdesigns.net/wp-content/plugins/dzs-portfolio/ap.swf"
,videoplayer_swflocation: "http://sbmdesigns.net/wp-content/plugins/dzs-portfolio/preview.swf"
,disable_itemmeta: "off"
,settings_ajax_loadmoremethod: "button"
,settings_mode_masonry_layout: "masonry"
,design_total_height_full: "off"
,settings_mode_masonry_layout_straightacross_setitemsoncenter: "off"
,design_item_height_same_as_width : "off"})
});
}
}
return false;
});
모든 것이 잘 작동하지만 때로는 afterLoad
이 실행되어 .load()
이 완료되기 전에 실행됩니다. 어쨌든 afterLoad
을 지연 시켜서 모든 것이로드되기 전에로드가 완료되었는지 확인하십시오. 인수 인 경우
행운이 문제를 해결하려면? – lukeocom
외부 파일에 함수를 배치하고 콜백에서 .getscript를 호출했습니다. – SBM