반응형
무한 스크롤 수동 트리거
잘 안 되는 것 같은데...:-(더 많은 불만을 봤지만 답을 못 찾겠어.
문제:무한 스크롤은 작동하지만 수동 트리거는 작동하지 않습니다.링크를 클릭해도 아무 일도 일어나지 않습니다.파이어버그가 주다
내 코드:
<?php echo ('<ul id="infinite">'); ?>
<?php
$wp_query = new WP_Query();
$wp_query->query('paged='.$paged.'&cat=5&showposts=3&meta_key=video_video&orderby=meta_value&order=ASC' . $post->ID);
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<?php if ( get_post_meta($post->ID, 'video_video', true) ) : ?>
<li class="video"><?php $home = array("h" => 290, "w" => 380, "zc" => 1, "q" =>100);
//echo get('video_video');
echo ('With: ');
echo get('participant_first_name');
echo (' ');
echo get('participant_last_name');
echo ('</li>');?>
<?php endif;?>
<?php endwhile;?>
<?php if (get_post_meta($post->ID, 'video_video', true) ) { ?>
<?php if ($wp_query->max_num_pages > 1) : ?>
<nav id="nav-below" >
<div id="next" >
<?php next_posts_link( __( 'Scroll down for more', 'intowntheme' ) ); ?></div>
</nav>
<?php endif; //end nav ?>
<?php } else { ?>
<p>There are no interviews at the moment </p>
<?php } ?>
</ul>
그리고 내 대본은:
jQuery('ul#infinite').infinitescroll({
navSelector : "#next", // selector for the paged navigation (it will be hidden)
nextSelector : "#next a", // selector for the NEXT link (to page 2)
itemSelector : "ul#infinite li", // selector for all items you'll retrieve
errorCallback: function() {
// fade out the error message after 2 seconds
$('#infscr-loading').animate({opacity: 0.8},2000).fadeOut('normal');
},
loading : {
msgText: "<em>Loading the next year of Grantees...</em>",
finishedMsg: "<em>You've reached the end of the Interviews.</em>"
},
});
//kill scroll binding
jQuery(window).unbind('.infscr');
//setTimeout("jQuery('#next').slideDown();", 1000);
//hook up the manual click guy.
jQuery('#next a').click(function(){
jQuery('#next a').infinitescroll('retrieve.infscr');
return false;
});
시도했다
jQuery(document).trigger('retrieve.infscr');
대신
jQuery('#next a').infinitescroll('retrieve.infscr');
운이 없더군
그러자 파이어버그가 말한다.
빠에, 찾았어...정상 문서 장수(이 플러그인은 사용할 수 없습니다!)
이것은, 다음과 같습니다.
jQuery('#next a').click(function(){
jQuery('#next a').infinitescroll('retrieve.infscr');
return false;
});
다음 항목이어야 합니다.
jQuery('#next a').click(function(){
jQuery('ul#infinite').infinitescroll('retrieve');
return false;
});
가장 큰 문제는 거기에 있어서는 안 될 .infscr 이었어요.다른 사람에게 도움이 되길..
문서와 같은 솔루션:
jQuery("#clickable_element").click(function(){
jQuery('#main_content_container').infinitescroll('retrieve');
return false;
});
주의:
석조 또는 동위원소를 사용하는 경우 수동 트리거 동작을 추가해야 할 수 있습니다.포함시키기만 하면 됩니다.manual-trigger.js무한대 이후를 지나쳐 그 행동을 굴리고 통과시킨다.behavior: 'twitter'플러그 인을 호출 시.
처음 클릭한 후 내비게이션 링크가 표시되는지 확인하기 위해 다음과 같이 수정했습니다.
jQuery("#clickable_element").click(function(){
jQuery('#main_content_container').infinitescroll('retrieve');
jQuery('#pagination').show();
return false;
});
어쩌면...$('#next a').클릭();
언급URL : https://stackoverflow.com/questions/10762656/infinite-scroll-manual-trigger
반응형
'programing' 카테고리의 다른 글
| WordPress에서 모든 게시물을 표시하는 방법 (0) | 2023.03.14 |
|---|---|
| 미발견 오류: 예상보다 적은 수의 후크가 렌더링되었습니다.리액트 훅의 우발적인 조기 반환 문구가 원인일 수 있습니다. (0) | 2023.03.14 |
| 각도가 있는 옵션 선택에서 공백 옵션 제거JS (0) | 2023.03.14 |
| React를 사용하여 현재 전체 URL을 읽으시겠습니까? (0) | 2023.03.14 |
| react+enzyme을 사용하여 요소 텍스트를 선택하는 방법 (0) | 2023.03.14 |