2013-07-27 175 views
1

我对我的投资组合正在开火,我使用了一个名为Gridly的wordpress主题,它使用masonry。我试图让帖子对齐到右侧而不是左侧。我碰到一个选项here,这将允许我通过使用“isOriginLeft”:false,但现在我只是不断收到此错误“未捕获的ReferenceError:砌体没有定义”,我没有更接近让帖子对齐正确。Uncaught ReferenceError:砌体未定义

我的投资组合是在这里: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' 
}); 
+0

您不需要多个jQuery文档就绪函数,您可以将三者的逻辑组合成一个;虽然做好多个准备好的功能是合法的,但是看到你的代码的任何人都会感到困惑。 –

+0

你在哪里引用'masonry'脚本? –

回答

-1

你在你的文档的顶部已经初始化砌筑:

$(document).ready(function() { 
    $('#post-area').masonry({ 
     // options 
     itemSelector : '.post', 
     // options... 
    isAnimated: true, 
    animationOptions: { 
     duration: 400, 
     easing: 'linear', 
     queue: false 
    } 

    }); 
}); 

,并在结束时,你重新初始化(不包括jQuery的):

var msnry = new Masonry(container, { 
    itemSelector: '.post' 
}); 

第二块是多余的并抛出错误。只要删除它。

+0

谢谢,这摆脱了那里的错误,但我仍然无法似乎得到的职位冲刷权?有什么建议么? – user2257001

+0

尝试将选项'isOriginLeft:false'直接添加到js-masonry选项。 – nirazul

+0

这似乎并不奏效...... – user2257001

相关问题