我在我的Rails应用程序中运行Galleria.IO的JavaScript图库,在开发环境和特别包含Galleria代码的生产环境页面上一切正常。但当你访问没有该代码的页面时,它会不停地抛出错误,例如:
No theme CSS loaded
Fatal error: Theme CSS could not load after 20 sec. Please download the latest theme at http://galleria.io/customer/
我已经将Galleria的文件包含在我的管道中:
// application.js
//= require galleria.min
//= require galleria.classic.min
/* application.css
*= require galleria.classic
*/
以下内容确实会在包含
#galleria
元素的页面上正确初始化图库,但在其他任何页面上都会引发上述错误:if ($("#galleria").length == 1) {
Galleria.loadTheme('/assets/galleria.classic.min.js');
Galleria.configure({
debug: false,
// imageCrop: true,
dummy: '/assets/fallback/large_default.png',
transition: 'fade'
});
Galleria.run('#galleria');
}
有没有一种方法可以使主题自动加载到资产管道中,而不必单独初始化它?