j查询同位素错误.停止在 Wordpress 中工作
jQuery Isotope error. Stopped working in Wordpress
几周前,在我的wordpress网站上添加了一些同位素,并使其运行良好。 但是,在对站点进行一些更改后,我现在收到一条错误消息,并且真的很难弄清楚是什么原因造成的,因为相同的代码在 JSFiddle 中运行良好,例如。http://jsfiddle.net/ttf5776r/12/
在我的站点上时,我在错误控制台中收到的错误消息是:
TypeError: i.data(...) 未定义 ...)n[t]=s||"original-order"!==t?rt:i.data(this,"isotope-sort-data")[t];i.da...
我已经发现,如果我删除以下代码,错误消息将停止出现并且同位素起作用,但由于已删除的代码,不会将所选框放入左上角。
$container
.isotope( 'updateSortData', $this.parent() ) //this should be above the 'return false;' to make the selected photo go to top left corner but it decided to break and havem't had time to find fix. - LOL 08-01-2015
.isotope( 'updateSortData', $previousSelected )
.isotope();
不幸的是,我不记得自从这工作以来我所做的所有更改,但我很确定没有进行任何 JQuery 修改。
谁能帮我排除故障?
代码如下:
函数.php
function add_isotope() {
wp_register_script('isotope', 'http://isotope.metafizzy.co/v1/jquery.isotope.min.js', array('jquery'));
wp_enqueue_script('isotope');
}
add_action( 'wp_enqueue_scripts', 'add_isotope' );
function add_jsscripts() {
wp_register_script('jsscripts', get_template_directory_uri() . '/js/scripts.js', array('jquery'));
wp_enqueue_script('jsscripts');
}
add_action( 'wp_enqueue_scripts', 'add_jsscripts' );
您的错误是指缩小的来源。第一步是切换到使用非缩小的源,以便变量具有其原始名称。
此时,您会在此处找到错误("键"变为"t"等):
updateSortData : function( $atoms, isIncrementingElemCount ) {
var instance = this,
getSortData = this.options.getSortData,
$this, sortData;
$atoms.each(function(){
$this = $(this);
sortData = {};
// get value for sort data based on fn( $elem ) passed in
for ( var key in getSortData ) {
if ( !isIncrementingElemCount && key === 'original-order' ) {
// keep original order original
sortData[ key ] = $.data( this, 'isotope-sort-data' )[ key ];
} else {
sortData[ key ] = getSortData[ key ]( $this, instance );
}
}
// apply sort data to element
$.data( this, 'isotope-sort-data', sortData );
});
},
你得到的错误,"i.data() is undefined",因此变成了"$.data() is undefined"——这似乎表明.data()
插件没有正确加载,或者(更有可能)传递给同位素的变量实际上不是 jQuery 库的句柄。检查如何加载和初始化同位素。
相关文章:
- 如何使MailHandler.php在Wordpress中工作
- .load ajax无法正常工作whitin wordpress主题
- 更新Wordpress和我的平滑滚动停止工作
- JS错误导致WordPress插件无法工作
- Wordpress WooCommerce添加到购物车,无法在移动网站上工作
- 谷歌地图API停止在Wordpress模板中工作
- 正在尝试获取此代码'在wordpress页面中工作的功能
- onmouseover无法在wordpress中工作
- wordpress 4.1 javascript停止工作
- 让Ajax为Wordpress上的所有用户工作
- j查询同位素错误.停止在 Wordpress 中工作
- WordPress jQuery灯箱突然不工作
- 无法让我的下拉菜单在基于引导的 Wordpress 主题中工作
- 我的Wordpress网站上的所有jQuery脚本都无法正常工作
- 导致WordPress管理部分无法工作的滚动代码
- 让jQuery在Wordpress中工作时遇到麻烦
- 为什么AJAX $.post不能在wordpress中工作
- JavaScript在纯HTML上工作,但不在Wordpress网站上工作
- JavaScript 不会在内容区域 wordpress 之外工作
- 如何让我的脚本在wordpress中工作