提供静态页面ember.js

时间:2014-11-20 17:17:10

标签: ember.js routing ember-data handlebars.js

我目前正在改造旧网站并添加了余烬。以前当用户去过产品时>产品有一个指向静态页面的链接。

路由到这些静态页面的最佳方式是什么? (对象中的销售表)

{
    id: 32,
    room: "String",
    subroom: "String",
    category: "String",
    image: "Content/Images/Products/img.PNG",
    name: "String",
    description: "String",
    bullets: [
        { content: "String" },
        { content: "String" },
        { content: "String" }
    ],
    sellsheet: "Content/Sellsheets/conveyor.html"
  }

1 个答案:

答案 0 :(得分:0)

我知道这不是最好的方式,但它符合我的需要。

我最后只是在产品页面底部的iframe中显示静态页面。每当你点击查看更多时,我用jQuery隐藏页面然后显示iframe,它通过锚标记加载html。然后我添加了一个“隐藏视图”按钮,隐藏了iframe并再次显示该页面。

<强> HTML

<script type="text/x-handlebars" id="product">
    <div id="valueprop-container">
      <div class="centered">
        <div class="col-left"><img {{bind-attr src=image}} /></div>
        <div class="col-right">
          <h2>{{{name}}}</h2>
          <p>{{{description}}}</p>
          <ul>
            {{#each bullets}}
            <li><span>{{{content}}}</span></li>
            {{/each}}
          </ul>
          {{#if sellsheet}}
            <a href="{{unbound sellsheet}}" target="frame" class="orange-button sell-sheet-click">View More</a>
          {{/if}}
        </div>
      </div>
    </div>
    <div class="shadow"></div>
    <div class="sellsheet">
      <button class="expand">View Less</button>
      <iframe name="frame" width="100%" height="100%" allowfullscreen style="position: absolute; border: none;"></iframe>
    </div>
  </script>

查看

App.ProductView = Ember.View.extend({
  didInsertElement: function(){
    var productPage = $('#valueprop-container');
    var sellSheet = $('.sellsheet');

    $('.sell-sheet-click').click('on', function(){
      productPage.hide();
      sellSheet.show();
    });

    $('.sellsheet').click('on', function(){
      productPage.show();
      sellSheet.hide();
    });
  }
});