두 기능을 나란히 사용하고 하나는 이미지를 변경하고 다른 하나는 줌 기능을 언 바인드하기 때문에, 다시 리 바인드하면 이미지가 변경되기 전에 두 번째 기능이 완료됩니다. 따라서 이미지가 변경되면 여전히 작동하지 않습니다.
두 번째 문제는 실제로 아무 것도 바인딩 해제하지 않은 것입니다.
그래서,로 변경 먼저 시도 :
$(".jqclass").unbind(".jqclass");
이 또는 당신이 jQuery를에 좀 더 마이그레이션 할 수 있습니다.
<div class="projectphotos">
<div id="photo_1">
<a href="http://designerspider.net/clients/jge/projects/h07_03_11_12_10_58.jpg" class="jqclass">
<img src="http://designerspider.net/clients/jge/projects/h07_03_11_12_10_58.jpg" class="projectimg2" alt="Mid 15th C Oakeshott Type XXa" />
</a>
</div>
<div id="photo_2" style="display:none;">
<a href="http://designerspider.net/clients/jge/projects/h07_03_11_12_19_49.jpg">
<img src="http://designerspider.net/clients/jge/projects/h07_03_11_12_19_49.jpg" class="projectimg2" alt="Mid 15th C Oakeshott Type XXa" />
</a>
</div>
<div class="thumbsdiv">
<ul class="thumbs">
<li>
<img rel="photo_1" src="http://designerspider.net/clients/jge/projects/h07_03_11_12_10_58.jpg" width="80" />
</li>
<li>
<img rel="photo_2" src="http://designerspider.net/clients/jge/projects/h07_03_11_12_19_49.jpg" width="80" />
</li>
</ul>
</div>
</div>
을 그리고 당신의 jQuery를 이렇게, 나는 각 라인 설명했습니다 :
당신 HTML은 다음과 같을 것이다 :
var options = {
zoomWidth: 250,
zoomHeight: 250,
position: 'right',
yOffset: 0,
xOffset: 0,
title: false
}
$(".jqclass").jqzoom(options);
// Make the thumbnail look clickable:
$(".thumbs img").each(function() {
$(this).css('cursor', 'pointer');
});
// React to clicking on a thumbnail:
$(".thumbs img").click(function() {
// Get the photo linked to:
var photo = $(this).attr('rel');
// Unbind the zoom:
$(".jqclass").unbind(".jqclass");
// Hide the current image via its parent DIV:
$(".jqclass").parent().hide();
// Remove teh jqclass:
$(".jqclass").removeClass("jqclass");
// Show the clicked photo:
$("#"+photo).show();
// Add the class and the zoom:
$("#"+photo+" a").addClass("jqclass").jqzoom(options);
});
거의 해결책이 있습니다. 코드를 보면 그것이 이해할 수있게되어서 고마워요. :) Onlt 작은 것은 첫 번째 이미지 이후의 모든 이미지에서 두 번째 유령 확대/축소 윈도우가 아무것도 보이지 않는다는 것입니다. ".jqclass") .jqzoom (options) 부분이 두 번 호출됩니다. 첫 번째 인스턴스를 꺼내면 빈 줌 창이 사라집니다 (자연스럽지 만 초기 이미지는 이미지를 바꿀 때까지 확대되지 않습니다). –
$ (".jqclass")에 onLoad 명령을 추가하는 방법이 있습니다 .jqzoom (options); 선? 그래서 페이지가 처음로드 될 때만 실행되고 그 후에는 click 함수의 줄을 사용하게됩니다. –
ok, 첫 번째 이미지의 이름을 jqclassorig로 지정하여 정렬했습니다. 그 후에 각각의 엄지 손톱은 jqclass를 호출하므로 반복 된 calass가 필요없고 추가 줌 상자가 필요 없습니다 :) –