首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >来自JSON的聚合物负载产品页面数据

来自JSON的聚合物负载产品页面数据
EN

Stack Overflow用户
提问于 2015-05-28 05:49:46
回答 1查看 514关注 0票数 0

在使用聚合物的电子商务商店应用程序时,我使用聚合物core-ajax加载产品数组,并使用核心动画页面显示产品缩略图和产品详细信息页(完整视图),但我只想在单击每个产品拇指时加载产品详细信息,如何做到这一点?

找到HTML

代码语言:javascript
复制
<div id="article-content" >
<template is="auto-binding" id="page-template" >
  <core-ajax
    id="ajaxpolo" auto
    url="./json/products.json"
    handleAs="json"
    on-core-response="{{handleResponse}}" response="{{headerList}}"  on-core-response="{{postsLoaded}}">
  </core-ajax>
  <core-animated-pages id="fpages" flex selected="{{$.polo_cards.selected}}" on-core-animated-pages-transition-end="{{transitionend}}" transitions="cross-fade-all slide-from-right">
    <section vertical layout>
      <div id="noscroll" fit hero-p>
        <div id="container" flex horizontal wrap around-justified layout cross-fade >
          <section on-tap="{{selectView}}" id="polo_cards" >
            <template repeat="{{item in headerList}}">
              <div class="card" vertical center center-justified layout hero-id="item-{{item.id}}" hero?="{{$.polo_cards.selected === item.id || lastSelected === item.id }}" > <span cross-fade hero-transition style="">{{item.name}}</span></div>
            </template>
          </section>
        </div>
      </div>
    </section>
    <template repeat="{{item in headerList}}">
      <section vertical layout>
        <div class="view" flex vertical center center-justified layout hero-id="item-{{item.id}}"    hero?="{{$.polo_cards.selected === item.id || $.polo_cards.selected === 0}}"	>
          <core-icon-button class="go_back" icon="{{$.polo_cards.selected != 0 ? 'arrow-back' : 'menu'}}" on-tap="{{goback}}"></core-icon-button>
          {{item.name}} <span cross-fade class="view-cont" style="height:1000px; overflow:scroll;"></span></div>
      </section>
    </template>
  </core-animated-pages>
</template>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-05-28 12:22:20

首先,将核心ajax的auto属性设置为false。auto="false",这将阻止核心-ajax从它自己抓取数据。然后在您想要成为单击/点击处理程序的元素上设置一个on -抽头或on-click属性。然后on-tap="{{getThem}}"创建函数。

代码语言:javascript
复制
getThem: function () {
  this.$.ajaxpolo.go();
}

那应该就够了。希望能帮上忙。

编辑:你会想要抓取更多的东西与你的事件。在单击/点击处理程序上,将希望获取的项的id添加到泛型属性。(远离正常属性。( dataId )我会叫它。

代码语言:javascript
复制
<div on-tap="{{getThem}}" dataId="{{product_id}}"></div>

然后,在您的功能,您得到了更多的事情,从事件,正如我前面说过的。

代码语言:javascript
复制
getThem: function (event, detail, sender) {
  var id = sender.attributes.dataId.value;
  // do something with id
}

我刚刚意识到,当你谈论php的时候,我可能误解了。抱歉的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30498186

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档