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!

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?
    – Michael
    Jul 18, 2014 at 6:31
  • 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 website
    – tommy-taco
    Jul 18, 2014 at 20:01
  • Could it be that you are not closing your <div class="box"> ?
    – Jackson
    Jul 25, 2014 at 11:45
  • 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!
    – tommy-taco
    Jul 25, 2014 at 20:38

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.