Cannot get Masonry-Rails Gem to work in my app
Asked Answered
C

1

7

so I have scoured stackoverflow and found some similar articles but nothing has worked for me yet. I am creating a rails app and I want to use the Masonry for my layout. I have tried uploading the js as described in this post, but I could not get it to work no matter how many times I tried (yes I matched all the correct IDs and classes). I know the gem is working because the CSS is loading fine, I just cant get the JS to work. Here is what I have at the moment

Gemfile:

# masonry layout
gem 'masonry-rails'

application.js:

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap
//= require_tree . 
//= require masonry/jquery.masonry  

index.html.erb:

<div class="center">

<div id="masonry-container" class="transitions-enabled infinite-scroll clearfix">
    <%= render @products %>
</div>

    <div class="paginator">
    <%= will_paginate @products, renderer: BootstrapPagination::Rails %>
    </div>
</div>

_products.html.erb

<div class="box">
<% gfyid = product.gfy.to_s.gsub("http://gfycat.com/", "") %>
<h2><%= product.name %></h2>
<div class="gfySize">
    <div class="gfyitem" data-title=false data-autoplay=false data-controls=false data-expand=false data-id="<%= gfyid %>"></div>
</div>

I am so lost, I have been working on this for hours trying everything. The CSS is working/looking fine but I am just struggling with the js. Would appreciate any help thank you so much!

Childs answered 18/7, 2014 at 0:1 Comment(4)
What is not working and what is not occurring that you expect to occur? Do you have any errors messages? Have you looked at your js console?Backplate
There are no error messages, and the css elements from the gem are working fine. The console doesn't bring anything up, just loading scripts from gfycat, as I am using their js plugin on my websiteChilds
Could it be that you are not closing your <div class="box"> ?Fortify
Hey sorry I did not come back to this, I ended up abondoning the gem and installing it manually, putting the masonry file in the vendors folder and writing the code in the product.js section. I think the latter is what fixed it, thanks!Childs
F
1

Try installing it manually, putting the masonry file in the vendors folder and writing the code in the product.js section.

Fractostratus answered 7/4, 2015 at 3:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.