[이윰] jQuery-1.8.3를 jQuery-1.9.x 이상으로 업그레이드시 masonry 오류 해결하기
페이지 정보
shadow2fox
1,953
2018.08.22 19:45
짧은주소
-
https://yadolee.com/tip/581 주소복사
평점
본문
jQuery-1.8.3를 jQuery-1.9.x 이상으로 업그레이드시 masonry 오류 해결하기
그누보드에 기본 탑재되어 사용되는 jQuery-1.8.3를 jQuery-1.9.x 이상으로 업그레이드할 경우 모달창과 무한스크롤과 연계된 masonry 소스로 인해 다음과 같은 오류가 나타난다.
cannot call methods on masonry prior to initialization; attempted to call method 'appended'
이윰빌더에서 제공하는 스킨 중 갤러리(시즌3) or 블로그(시즌2) 스킨 list.skin.html를 열어 다음과 같이 수정한다.
수정 전
cannot call methods on masonry prior to initialization; attempted to call method 'appended'
이윰빌더에서 제공하는 스킨 중 갤러리(시즌3) or 블로그(시즌2) 스킨 list.skin.html를 열어 다음과 같이 수정한다.
수정 전
function( newElements ) {
var $newElems = $( newElements ).css({ opacity: 0 });
$newElems.imagesLoaded(function(){
$newElems.animate({ opacity: 1 });
$container.masonry( 'appended', $newElems, true );
});
var gutter = 17;
var min_width = 170;
$container.imagesLoaded( function(){
$container.masonry({
itemSelector : '.gallery-item',
gutterWidth: gutter,
isAnimated: true,
columnWidth: function( containerWidth ) {
var windowSize = $(window).width();
if (windowSize > 1199) {
var box_width = (((containerWidth - 2*gutter)/3) | 0) ;
if (box_width < min_width) {
box_width = (((containerWidth - gutter)/3) | 0);
}
} else if (windowSize <= 1199 && windowSize > 766) {
var box_width = (((containerWidth - 1*gutter)/2) | 0) ;
if (box_width < min_width) {
box_width = (((containerWidth - gutter)/2) | 0);
}
} else if (windowSize <= 766 && windowSize > 566) {
var box_width = (((containerWidth - 1*gutter)/2) | 0) ;
if (box_width < min_width) {
box_width = (((containerWidth - gutter)/2) | 0);
}
} else {
var box_width = (((containerWidth - 0*gutter)/1) | 0) ;
if (box_width < min_width) {
box_width = (((containerWidth - gutter)/1) | 0);
}
}
if (box_width < min_width) {
box_width = containerWidth;
}
$('.gallery-item').width(box_width);
setTimeout(function() {
$('.gallery-item').show();
}, 0);
return box_width;
}
});
});
});
수정 후
function( newElements ) {
var gutter = 17;
var min_width = 170;
$container.imagesLoaded( function(){
$container.masonry({
itemSelector : '.gallery-item',
gutterWidth: gutter,
isAnimated: true,
columnWidth: function( containerWidth ) {
var windowSize = $(window).width();
if (windowSize > 1199) {
var box_width = (((containerWidth - 2*gutter)/3) | 0) ;
if (box_width < min_width) {
box_width = (((containerWidth - gutter)/3) | 0);
}
} else if (windowSize <= 1199 && windowSize > 766) {
var box_width = (((containerWidth - 1*gutter)/2) | 0) ;
if (box_width < min_width) {
box_width = (((containerWidth - gutter)/2) | 0);
}
} else if (windowSize <= 766 && windowSize > 566) {
var box_width = (((containerWidth - 1*gutter)/2) | 0) ;
if (box_width < min_width) {
box_width = (((containerWidth - gutter)/2) | 0);
}
} else {
var box_width = (((containerWidth - 0*gutter)/1) | 0) ;
if (box_width < min_width) {
box_width = (((containerWidth - gutter)/1) | 0);
}
}
if (box_width < min_width) {
box_width = containerWidth;
}
$('.gallery-item').width(box_width);
setTimeout(function() {
$('.gallery-item').show();
}, 0);
return box_width;
}
});
});
var $newElems = $( newElements ).css({ opacity: 0 });
$newElems.imagesLoaded(function(){
$newElems.animate({ opacity: 1 });
$container.masonry( 'appended', $newElems, true );
});
});
소스를 보면 알겠지만 masonry가 무한스크롤보다 먼저 초기화되야 언급된 오류가 일어나지 않는다.
이윰빌더
jQuery
1.8.3
1.9.x
이상
업그레이드
masonry
masonry prior to initialization
attempted to call method
appended
오류
해결하기
추천인
레벨 142
경험치 3,034,631
Progress Bar 74%
- 가입일 : 2015-03-10 12:21:44
- 서명 : 인간에게 가장 큰 선물은
자기 자신에게 기회를 주는 것이다.
- 크리스 가드너, Chris Gardner -
- 자기소개 : There's never a shortcut to happiness.
-
[골라먹는 요리] 햄 계란밥2024-04-28
-
1 [짤방 게시판] 토키짱 - 주간 플레이보이 2024 No.102024-04-23
-
1 🔞[짤방 게시판] 야마사키 마미 - 주간 플레이보이 2024 No.102024-04-23
-
[짤방 게시판] 이케다 레이라 - 주간 플레이보이 2024 No.102024-04-23
-
1 [짤방 게시판] 이리키 마리 - 주간 플레이보이 2024 No.102024-04-23
-
[뮤직 비디오 게시판] November Rain - Guns N' Roses [Use Your Illusion I] 1991년2024-04-22
-
[뮤직 비디오 게시판] Sweet Child O' Mine - Guns N' Roses [Appetite for Destruction] 1987년2024-04-21
-
1 [짤방 게시판] 타카츠루 모모하 - 주간 플레이보이 2024 No.102024-04-20
-
[생활 정보] 100원이 넘는 적립 금액은 최초이지 않나 싶네요 고생하셨습니다{이모티콘}2024-04-23
-
[자유 게시판] 부활 곡에 잘 어울릴 듯 한 보이스 컬러네요 동감입니다2024-03-31
-
[생활 정보] 80원의 행복이네요{이모티콘}2024-03-21
-
[자유 게시판] 같은 의견이에요2024-03-14
-
[자유 게시판] 다시 봐도 감동입니다{이모티콘}2024-03-11
-
[자유 게시판] 제가 라이브 시청을 하지 않아야 대활약을 해서 손흥민 선수를 위해 안타깝지만 자제 중입니다{이모티콘} 반더벤 또한 너무 잘하지 않았나 싶었네요2024-03-03
-
[자유 게시판] 하늘구장님 늘 감사드리며 마음을 담아 새해 인사를 전합니다 새해 복 많이 받으세요2024-02-09
-
[이슈와 관심] 최소 누군가는 가학 대통령으로 기억할 것 같습니다2024-01-29
댓글
첫 번째 댓글을 남겨 주세요