【发布时间】:2013-07-27 10:58:20
【问题描述】:
我正在处理我的作品集,我正在使用一个名为 Gridly 的 wordpress 主题,它使用 masonry。我正在努力使帖子向右而不是向左对齐。我遇到了一个选项here,它允许我通过使用 "isOriginLeft": false 来做到这一点,但现在我只是不断收到这个错误 "Uncaught ReferenceError: Masonry is not defined",而且我离让帖子更近了右对齐。
我的作品集在这里:brittonhack.com/new/
jQuery 不是我的强项,所以任何帮助都将不胜感激。谢谢!
这是不断产生错误的代码。
// masonry code
$(document).ready(function() {
$('#post-area').masonry({
// options
itemSelector : '.post',
// options...
isAnimated: true,
animationOptions: {
duration: 400,
easing: 'linear',
queue: false
}
});
});
// hover code for index templates
$(document).ready(function() {
$('#post-area .image').hover(
function() {
$(this).stop().fadeTo(300, 0.8);
},
function() {
$(this).fadeTo(300, 1.0);
}
);
});
// comment form values
$(document).ready(function(){
$("#comment-form input").focus(function () {
var origval = $(this).val();
$(this).val("");
//console.log(origval);
$("#comment-form input").blur(function () {
if($(this).val().length === 0 ) {
$(this).val(origval);
origval = null;
}else{
origval = null;
};
});
});
});
// clear text area
$('textarea.comment-input').focus(function() {
$(this).val('');
});
var container = document.querySelector('#post-area');
var msnry = new Masonry( container, {
itemSelector: '.post'
});
【问题讨论】:
-
您不需要多个jQuery文档准备功能,您可以将您拥有的三个逻辑合二为一;虽然执行多个就绪函数是合法的,但其他人查看您的代码时会感到困惑。
-
你在哪里引用
masonry脚本?