我正在使用Smooth Div Scroll jQuery Plugin在網站上移動幻燈片。加載到電影膠片中的圖像是自定義發佈類型,每個圖像都有一個標題幷包含單個圖像。該插件在包含任意數量圖像的長div上水平滾動。我的問題是,即使在圖像消失之後,我仍然可以滾動顯示無限的時間。如何在WordPress中加載帖子後運行jQuery方法?
這裏是我的問題的故障:
- 我已經使用普通圖像後循環,而不是試圖 ,一切 預期一樣(沒有無限 滾動)。
- 我試過在document.ready和window.load之間設置腳本,使用document.ready它們根本不加載。
- 我試過調用一個公共函數「recalculateScrollableArea」,以便可以在圖像加載無效後計算該區域,然後通過在腳本中調用jQuery中的警告框,我可以看到它仍然被調用在圖像加載之前。
那應該怎麼看平時: 如何看起來,當它過卷軸:
的平滑股利滾動代碼和下面的初始化代碼都被稱爲在頁腳底部:
jQuery(window).load(function() {
jQuery("div#makeMeScrollable").smoothDivScroll({
autoScroll: "onstart" ,
autoScrollDirection: "backandforth",
autoScrollStep: 1,
autoScrollInterval: 15,
visibleHotSpots: "always"
});
這就是我所做的嘗試和修正調整大小:
jQuery(document).ready(function() {
jQuery("#makeMeScrollable").smoothDivScroll("disable");
});
我還要提到,對於職位的圖像由「P」標籤包圍,但我不明白爲什麼這將是問題。
感謝您的閱讀!
編輯: 下面是一些更多的代碼,其中大部分是股票,當只是普通IMGS的地方,而不是循環工作。
底座CSS和jQuery文件是相同的,在這個簡單的演示的那些:http://www.smoothdivscroll.com/basicDemo.htm
jQuery和jQuery UI的進口(工作)
function jQuery_from_Google() {
if (!is_admin()) { // actually not necessary, because the Hook only get used in the Theme
wp_deregister_script('jquery'); // unregistered key jQuery
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js', false, '1.5.2'); // register key jQuery with URL of Google CDN
wp_enqueue_script('jquery'); // include jQuery
}
}
// nur for Themes since WordPress 3.0
add_action('after_setup_theme', 'jQuery_from_Google'); // Theme active, include function
function jQueryUI_from_Google() {
if (!is_admin()) { // actually not necessary, because the Hook only get used in the Theme
wp_register_script('jqueryui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js'); // register key jQueryUI with URL of Google CDN
wp_enqueue_script('jqueryui'); // include jQueryUI
}
}
// nur for Themes since WordPress 3.0
add_action('after_setup_theme', 'jQueryUI_from_Google'); // Theme active, include function
進口發生在頁腳底部:
<?php // Smooth Div Scroll inport for filmstrip galleries ?>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/javascript/filmstrip.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/SmoothDivScroll-1.1/js/jquery.smoothDivScroll-1.1-min.js"></script>
</body>
</html>
這裏是一個部分的代碼片段,它使用的內容的循環:
<?php if(is_page('engagements')) { ?>
<div id="makeMeScrollable">
<div class="scrollingHotSpotLeft"></div>
<div class="scrollingHotSpotRight"></div>
<div class="scrollWrapper">
<div class="scrollableArea">
<?php
$args = array('post_type' => 'engagement_photos');
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post();
the_content();
endwhile;
?>
</div>
</div>
</div>
<?php } else if(is_page('weddings')) { ?>
這裏是WordPress中添加圖像的例子:
所有瀏覽器?鏈接到您的網頁? – Sparky
我現在正在本地主機服務器上開發,所以它仍然不在線。所有瀏覽器都出現這個問題。 – mitchellbutler
如果您發佈了所有相關的代碼,那麼可能會有所幫助......但是到目前爲止發佈的內容可以完成很多故障排除工作。 – Sparky