2010-11-05 91 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的旧版本。

删除让我的滑块开始工作。