0
我已經在我的開發站點中添加了打包工具來玩弄新的佈局 - 它工作的很好,所以我將相同的代碼彙編到生產中。出於某種原因,它不會通過我的產品實例執行。當我運行預編譯時,我最初的想法是它的代碼排序問題。爲什麼我的打包代碼不能執行?
Here is my dev instance顯示工作代碼。 Here is my prod instance代碼似乎沒有初始化。
這裏是我的CSS:
/* Packery */
.item-content {
border-color: hsla(0, 0%, 100%, 0.4);
-webkit-transition: width 0.4s, height 0.4s;
-moz-transition: width 0.4s, height 0.4s;
-o-transition: width 0.4s, height 0.4s;
transition: width 0.4s, height 0.4s;
}
.item.is-expanded {
z-index: 2;
}
我的jQuery:
//Packery
var $container = $('.packery').packery();
$container.on('click', '.item', function(event) {
var $item = $(event.currentTarget);
var isExpanded = $item.hasClass('is-expanded');
$item.toggleClass('is-expanded');
if (isExpanded) {
// if shrinking, just layout
$container.packery();
} else {
// if expanding, fit it
$container.packery('fit', event.currentTarget);
}
});
我目前沒有在未來使用點擊特徵,但還沒有計劃,所以它仍然在代碼中。
而且我的html:
<div id="container" class="packery">
<%= render partial: 'shared/show_projects', collection: @projects %>
</div>
部分:
<div class="item capsule span6">
<p>
<div class="row">
<div class="span4">
SNIP!
</div>
</div>
</p>
</div>
難道說當我的預編譯運行,我的jQuery是插在上面packery.js,所以它不按預期初始化?
你確定'packery'在生產中被加載嗎?你運行 - $('。packery')。packery();在控制檯中? 您是否將packery添加到需要預編譯的資產中 config.assets.precompile + =%w(packery.js) – marvwhere