2014-03-12 62 views
0

这是live site我搞乱了。jquery插件tinysort不工作,不知道为什么

使用php通过get_field()调用每张图片上的数字。 (我使用插件“高级自定义字段”来创建一个字段,在创建帖子时我输入一个数字,在这种情况下,它是蛋白质数量。然后我用php调用它,使它显示在图片的顶部,如下所示:

<?php 
$protein = get_field('grams_of_protein'); 
?> 

<div class="portfoliooverlay"><a href="<?php the_permalink(); ?>"><span class="jrm-protein"><?php echo "$protein"; ?></span></a></div> 

我添加了一个跨度类.jrm蛋白,使我可以定位在页面上所有可见的帖子的跨度,因为它们都具有相同的HTML结构,都含有.jrm蛋白。

我试图使用jQuery插件TinySort

在网站上的侧边栏按钮标记为“排序”具有以下JS:

jQuery(document).ready(function() { 

jQuery('#sorting-button').click(function() { 
     jQuery('.jrm-protein').tsort(); 
    }); 
}); 

有人可以看看网站,并找出它为什么不工作?

我没有注册插件脚本,只需排队就这样在我的functions.php

wp_enqueue_script('jrm-custom-tinysortjs', get_template_directory_uri() . '/js/jrmcustomtinysort.js', array('jquery'), false); 
wp_enqueue_script('jrm-customjs', get_template_directory_uri() . '/js/jrmcustom.js', array('jquery'), false); 

在一个侧面说明,我添加了一个覆盖时的按钮是切换整个页面点击,只是为了确保并告诉你,JS文件正在工作。或者至少第二个是。

============================================== ===================================

更新:我添加一个div一堆跨越底部,它与这些工作,所以我想问题是我怎么能让它跨不同的容器工作?应该只是一个选择的问题(但不知道如何做到这一点)

回答

0

我不想调试整个网站的计划,但我会第一个错误我看到的帮助:

Uncaught TypeError: Cannot call method 'getElementsByTagName' of null

var container = document.getElementById('site-navigation'), 
    button = container.getElementsByTagName('h1')[0], 
    menu  = container.getElementsByTagName('ul')[0]; 

你设置容器的单个元素,而不是document对象。无论是在其他2线改变containerdocument或更改

var container = document.getElementById('site-navigation'), 

var container = document, 
+0

感谢的是,它是在主题JS错误。但我主要关心的是我上面所描述的。我认为这是我选择要排序的方式。不确定tinysort将跨越不同的容器。 –

相关问题