2010-11-05 87 views
0

好的,所以這是我的問題。Jquery - 精選內容滑塊不工作

我一直花費大概10個小時試圖在我的網站上放置一個精選內容滑塊。嘗試我能想到的任何事情。嘗試可能3個不同版本的相同的滑塊。

的網址是:http://www.heartofphoto.com/slidetest/

但不管怎麼說,這裏是我目前有打算:

在標頭,我已經成功地得到這樣的:

<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script> 
<script type='text/javascript'>try{jQuery.noConflict();}catch(e){};</script> 
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.3/jquery-ui.min.js'></script> 

具有或不具有「noconflict」部分似乎沒有什麼區別。我相信在我爲Wordpress安裝「google libary」插件後,noconflict部分進來了。

這裏是劇本,我有頁面內應顯示滾動條:

<script type="text/javascript"> 

jQuery(document).ready(function(){ 
    jQuery("#featured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true); 
}); 
</script> 

有了這樣一個在「featured.php」文件我做了,還是有它在的header.php包含在頂部的文件沒有區別。

所以,任何人都有線索我做錯了什麼?

部分編輯: 我得到錯誤SCRIPT438:對象不支持slidetest此屬性或方法,行139字3. 這是這一行:

jQuery("#featured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true); 

而對於那些你想要的看到我的HTML。這個版本實際上是用一個PHP的設置來獲得數據:

<div id="featured" > 
     <ul class="ui-tabs-nav"> 
<?php 
$postcount = 0; 
$featured_query = new WP_Query('cat=29'); 
while ($featured_query->have_posts()) : $featured_query->the_post(); 
    get_the_ID(); 
    $postcount++; 
?> 
<?php 
// get the image filename 
$value_feat_img = get_post_custom_values("thumbnail"); 
if (isset($value_feat_img[0])) { ?> 
     <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-<?php echo $postcount; ?>"><a href="#fragment-<?php echo $postcount; ?>"> 

     <img src="<?php echo bloginfo('template_url'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "thumbnail", $single = true); ?>&amp;h=50&amp;w=80&amp;zc=1&amp;q=95" alt="<?php the_title(); ?>" /><span><?php the_title(); ?></span></a><?php } ?> 
</li> 
      <?php endwhile; ?> 

     </ul> 

<?php 
$postcount = 0; 
$featured_query = new WP_Query('cat=29'); 
while ($featured_query->have_posts()) : $featured_query->the_post(); 
    get_the_ID(); 
$postcount++; 
?> 

    <!-- Content --> 
    <div id="fragment-<?php echo $postcount; ?>" class="ui-tabs-panel" style=""> 
    <?php // get the image filename 
         $value_img = get_post_custom_values("thumbnail"); 

if (isset($value_img[0])) { ?>    

     <img src="<?php echo bloginfo('template_url'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "thumbnail", $single = true); ?>&amp;h=300&amp;w=390&amp;zc=1&amp;q=95" alt="<?php the_title(); ?>" /> 

     <?php } ?> 
     <div class="info" > 

      <h2><a href="<?php the_permalink() ?>" ><?php the_title(); ?></a></h2> 
      <?php the_excerpt(); ?> 
     </div> 
    </div> 
<?php endwhile; ?> 

</div> 
+0

控制檯中是否有錯誤? – Harmen 2010-11-05 17:49:02

+0

你的html是什麼樣的? – generalhenry 2010-11-05 17:53:05

+0

我得到這個「SCRIPT438:對象不支持此屬性或方法」在slidetest,線路139字符3. 至極是 的jQuery(「#精選」)標籤({FX:{不透明:「切換」 }})。tabs(「rotate」,5000,true); row – Alexander 2010-11-05 18:09:57

回答

0

可能是一個愚蠢的問題,但是,是在谷歌圖書館在調用代碼居然還有所有的空格? IE

<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2 /jquery.min.js'></script> 

我問,因爲這並不是jQuery的一個有效參考,因此,如果有衝突或沒有也沒關係,jQuery將不能被定義。

+0

這很奇怪,因爲當我看着我的頁面時,我不會看到它。我實際上使用wordpress函數來加載庫。 (wp_enqueue_script) – Alexander 2010-11-05 18:28:06

+0

我現在意識到我在寫我的文章時意外添加了它。不,不應該在那裏。 – Alexander 2010-11-05 20:16:37

0

似乎這個主題的原創者曾經以一種笨拙的方式在頁腳中關閉了jQuery的舊版本。

刪除讓我的滑塊開始工作。