1

我在我的 RoR 项目中实施 Masonry 时遇到了一些麻烦。

我想我可以用当前网页更好地解释它:http: //sttorybox.herokuapp.com/

如您所见,如果您打开页面,砌体工作正常。但是,例如,您进入一个故事的单个页面(您必须登录-> user:test@test.com,pass:test),单击框中的标题(第一个框,它是由测试用户创建的) ,现在单击页面标题:顶部栏砌体中的 STTORYBOX 现在不起作用,我不知道为什么:/

这是我的 JS 代码:

$(function() {
  var options = {
    itemSelector: ".item",
    isAnimated: true,
    layoutPriorities:{
      upperPosition: 1,
      shelfOrder: 1
    }
  }

  $container = $("#items").masonry(options);
});

我希望你们能帮助我。提前致谢。

4

1 回答 1

1

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.

于 2014-05-15T19:22:03.850 回答