Reputation: 6316
I'm having some troubles implementing Masonry in my RoR project.
I think I can explain it better with the current web page: http://sttorybox.herokuapp.com/
As you can see, if you open the page, masonry is working fine. But, for example, you go into a story individual page (you must be logged in-> user:[email protected] , pass:test), clicking on title in the box (first box, it was created by test user), and now click in the title of the page: STTORYBOX in the top bar masonry now is not working and I don't know why :/
Here is my JS code:
$(function() {
var options = {
itemSelector: ".item",
isAnimated: true,
layoutPriorities:{
upperPosition: 1,
shelfOrder: 1
}
}
$container = $("#items").masonry(options);
});
I hope you guys can help me. Thanks in advance.
Upvotes: 1
Views: 374
Reputation: 6316
I solved the issue, the problem was some behaviour of turbolink rails gem.
The solution was to add all my content as a anonymous function like that:
var content = function() {
... content ...
};
And later using turbolinks function page:load in order to execute my code again
$(document).on('page:load', content);
Also I had to add this regular jquery function to load my content too:
$(document).ready(content);
I hope this help some people.
Upvotes: 1