[이윰] jQuery-1.8.3를 jQuery-1.9.x 이상으로 업그레이드시 masonry 오류 해결하기
페이지 정보
![](https://yadolee.com/data/member/profile/shadow2fox.jpg?1428739773)
짧은주소
-
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
오류
해결하기
추천인
![](https://yadolee.com/data/member/profile/shadow2fox.jpg?1428739773)
레벨 143
경험치 3,055,207
Progress Bar 22%
- 가입일 : 2015-03-10 12:21:44
- 서명 : 인간에게 가장 큰 선물은
자기 자신에게 기회를 주는 것이다.
- 크리스 가드너, Chris Gardner -
- 자기소개 : There's never a shortcut to happiness.
-
[생활 정보] 지난번 물티슈 구매용도로 잘 사용했습니다 감사함을 전합니다2024-06-19
-
[이슈와 관심] 결코 진실은 가려지지 않을 거라 생각합니다.2024-05-29
-
[생활 정보] 100원이 넘는 적립 금액은 최초이지 않나 싶네요 고생하셨습니다{이모티콘}2024-04-23
-
[자유 게시판] 부활 곡에 잘 어울릴 듯 한 보이스 컬러네요 동감입니다2024-03-31
-
[생활 정보] 80원의 행복이네요{이모티콘}2024-03-21
-
[자유 게시판] 같은 의견이에요2024-03-14
-
[자유 게시판] 다시 봐도 감동입니다{이모티콘}2024-03-11
-
[자유 게시판] 제가 라이브 시청을 하지 않아야 대활약을 해서 손흥민 선수를 위해 안타깝지만 자제 중입니다{이모티콘} 반더벤 또한 너무 잘하지 않았나 싶었네요2024-03-03
댓글
첫 번째 댓글을 남겨 주세요