【问题标题】:Adding Adobe Edge Scripts into Rails Asset Pipeline将 Adob​​e Edge 脚本添加到 Rails 资产管道
【发布时间】:2013-04-21 21:47:36
【问题描述】:

这可能是一个简单的案例,将带有依赖关系的外部脚本引入 Rails。

我正在尝试让我的 Adob​​e Edge 生成的动画在我的 Rails 应用程序中工作,第一步是包含所有 Adob​​e Edge 生成的 js 文件,但到目前为止我只是得到一堆 404我在 Application.js 文件中包含的所有 Edge 文件均未找到错误

这是我的 Application.js 文件

//= require jquery
//= require jquery_ujs
//= require underscore
//= require backbone
//= require california_internet
//= require hero_edgePreload
//= require edge_includes/edge.1.5.0.min
//= require hero_edge
//= require hero_edgeActions

这是 Edge 的 Preloader.js 尝试查找某些文件的方式...

aLoader=[{load:"edge_includes/jquery-1.7.1.min.js"},{load:"edge_includes/edge.1.5.0.min.js"},{load:"hero_edge.js"},{load:"hero_edgeActions.js"}]

【问题讨论】:

    标签: javascript jquery ruby-on-rails asset-pipeline adobe-edge


    【解决方案1】:

    我让它工作的方式是将hero_edgePreload.js更改为hero_edgePreload.js.erb

    然后改变:

    aLoader=[
      {load:"edge_includes/jquery-1.7.1.min.js"},
      {load:"edge_includes/edge.1.5.0.min.js"},
      {load:"hero_edge.js"},
      {load:"hero_edgeActions.js"}
    ];
    

    收件人:

    aLoader=[
      // {load:"edge_includes/jquery-1.7.1.min.js"}, Already required in application.js
      {load:'<%= asset_path("edge.1.5.0.min.js") %>'},
      {load:'<%= asset_path("hero_edge.js") %>'},
      {load:'<%= asset_path("hero_edgeActions.js") %>'}
    ];
    

    您也可以在 application.js 中从您的要求中删除任何 Adob​​e Edge JS 文件。

    您必须将asset_path 添加到hero_edge.js 中的任何图像,并将其更改为hero_edge.js.erb

    如果有更简单的方法,我很想知道:)

    【讨论】:

      【解决方案2】:

      Michael Johnston 更改 Edge 的 aLoader 路径的解决方案有效,但会出错。在本地主机上,我会随机获得Uncaught HierarchyRequestError: A Node was inserted somewhere it doesn't belong.,而在每次页面刷新时部署到 Heroku 之后。

      此外,我的应用程序已经在更高版本中依赖 jQuery - 因此从 Edge 动画添加一个可能会导致冲突。

      经过反复试验,我决定使用此解决方案:

      1. 将整个动画放到/public/edge文件夹中
      2. 将动画放入 iframe:&lt;iframe class="animation-container" src='/edge/animation.html' /&gt;

      不是最优雅的,但肯定省了很多麻烦。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-10-05
        • 1970-01-01
        • 2012-07-07
        • 2014-09-25
        • 2015-01-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多