我一直在尝试实现 jQuery Masonry,但它一直无法正常工作。
它出错并在浏览器控制台中显示此内容。
未捕获的类型错误:对象 [object Object] 没有方法“imagesLoaded”
Masonry 在 Vendor/asset/javascripts 中
好的,这是我的文件。
技能.js.coffee:
jQuery ->
$('#skills_page').imagesLoaded ->
$('#skills_page').masonry itemSelector: ".box"
index.html.haml
.container
#skills_page
= render @skills
= will_paginate @skills
custon.css.scss
.box {
background-color: #fff;
width: 214px;
margin: 5px;
float: left;
-webkit-box-shadow: 1px 100px 6px rgba(0, 0, 0, .375);
-moz-box-shadow: 1px 100px 6px rgba(0,0,0,.375);
box-shadow: 1px 1px 6px rgba(0, 0, 0, .375);
display: block;
}
.box img {
diplay: block;
width: 100%;
}
.description {
margin: 10px 0 5px;
}
_skill.html.haml
.box
.pin_container
- if skill.image.file?
.pin_image_bkg= image_tag(skill.image(:long))
- else
.pin_image_bkg= image_tag "214by70.png"
- if skill.user.profile_pic.file?
.pin_image= image_tag(skill.user.profile_pic(:medium), :style => "-webkit-border-top-left-radius: 5px;-webkit-border-top-right-radius: 5px;-moz-border-radius-topleft: 5px;-moz-border-radius-topright: 5px;-webkit-border-bottom-right-radius: 7px;-webkit-border-bottom-left-radius: 7px;-moz-border-radius-bottomright: 7px;-moz-border-radius-bottomleft: 7px;")
- else
.pin_image= image_tag("default_avatar.png", :style => "-webkit-border-top-left-radius: 5px;-webkit-border-top-right-radius: 5px;-moz-border-radius-topleft: 5px;-moz-border-radius-topright: 5px;-webkit-border-bottom-right-radius: 7px;-webkit-border-bottom-left-radius: 7px;-moz-border-radius-bottomright: 7px;-moz-border-radius-bottomleft: 7px;")
.pin_btn= link_to 'View', skill, :class => "btn"
.pin_subtitle
Help Package from
=link_to "#{skill.user.name}" , skill.user
.pin_title
=link_to "#{skill.title}", skill
.mini_info
-unless skill.work_hrs.blank?
.left
.mini_hours= skill.work_hrs
.left
.mini_title W
-unless skill.meeting_hrs.blank?
.left
.mini_hours= skill.meeting_hrs
.left
.mini_title M
.clear
这是您查看页面源代码时我的脚本的样子:)
<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery.masonry.min.js?body=1" type="text/javascript"></script>
<script src="/assets/twitter/bootstrap/bootstrap-transition.js?body=1" type="text/javascript"></script>
<script src="/assets/twitter/bootstrap/bootstrap-alert.js?body=1" type="text/javascript"></script>
<script src="/assets/twitter/bootstrap/bootstrap-modal.js?body=1" type="text/javascript"></script>
<script src="/assets/twitter/bootstrap/bootstrap-dropdown.js?body=1" type="text/javascript"></script>
<script src="/assets/twitter/bootstrap/bootstrap-scrollspy.js?body=1" type="text/javascript"></script>
<script src="/assets/twitter/bootstrap/bootstrap-tab.js?body=1" type="text/javascript"></script>
<script src="/assets/twitter/bootstrap/bootstrap-tooltip.js?body=1" type="text/javascript"></script>
<script src="/assets/twitter/bootstrap/bootstrap-popover.js?body=1" type="text/javascript"></script>
<script src="/assets/twitter/bootstrap/bootstrap-button.js?body=1" type="text/javascript"></script>
<script src="/assets/twitter/bootstrap/bootstrap-collapse.js?body=1" type="text/javascript"></script>
<script src="/assets/twitter/bootstrap/bootstrap-carousel.js?body=1" type="text/javascript"></script>
<script src="/assets/twitter/bootstrap/bootstrap-typeahead.js?body=1" type="text/javascript"></script>
<script src="/assets/twitter/bootstrap/bootstrap-affix.js?body=1" type="text/javascript"></script>
<script src="/assets/twitter/bootstrap.js?body=1" type="text/javascript"></script>
<script src="/assets/applications.js?body=1" type="text/javascript"></script>
<script src="/assets/pages.js?body=1" type="text/javascript"></script>
<script src="/assets/password_resets.js?body=1" type="text/javascript"></script>
<script src="/assets/skills.js?body=1"