简体   繁体   English

聚合物dom-repeat和铁ajax调用的显示结果

[英]Polymer dom-repeat and displaying result of iron-ajax call

I have a feed of GP Practice addresses the start of which is as follows (not the whole feed which is over 16000 entries - still got to figure out paging) 我有一个GP Practice的提要,其开头如下(不是整个提要超过16000个条目-仍然需要弄清楚分页)

    [{"Address1":"73 UPPER WICKHAM LANE","Address2":"WELLING","Address3":"KENT","Address4":"","Address5":"","CloseDate":"\/Date(-62135596800000+0000)\/","ContactName":"","ContactTelephone":"020 88541910","EmailAddress":"","LastUpdatedDate":"\/Date(1434749040000+0100)\/","Name":"(GPSI) DR AC BARUAH","OpenDate":"\/Date(-62135596800000+0000)\/","OrgSubTypeCode":"B","PCTCode":"TAK","Postcode":"DA16 3AF","PracticeCode":"Y00789","PracticeType":"0","SendToEDTHub":false,"SendToEmail":false,"SendToPrinter":true,"Status":"C"},
{"Address1":"73 UPPER WICKHAM LANE","Address2":"","Address3":"WELLING","Address4":"KENT","Address5":"","CloseDate":"\/Date(-62135596800000+0000)\/","ContactName":"","ContactTelephone":"020 88541910","EmailAddress":"","LastUpdatedDate":"\/Date(1434749040000+0100)\/","Name":"(GPSI) DR AP DHITAL","OpenDate":"\/Date(-62135596800000+0000)\/","OrgSubTypeCode":"B","PCTCode":"TAK","Postcode":"DA16 3AF","PracticeCode":"Y00788","PracticeType":"0","SendToEDTHub":false,"SendToEmail":false,"SendToPrinter":true,"Status":"C"},
{"Address1":"2 CHURCH AVENUE","Address2":"","Address3":"SIDCUP","Address4":"KENT","Address5":"","CloseDate":"\/Date(-62135596800000+0000)\/","ContactName":"","ContactTelephone":"020 83021114","EmailAddress":"","LastUpdatedDate":"\/Date(1434749040000+0100)\/","Name":"(GPSI) DR HL BHATTAD","OpenDate":"\/Date(-62135596800000+0000)\/","OrgSubTypeCode":"B","PCTCode":"TAK","Postcode":"DA14 6BU","PracticeCode":"Y00791","PracticeType":"0","SendToEDTHub":false,"SendToEmail":false,"SendToPrinter":true,"Status":"C"}
    .
    .
    .

this is returned with the mime-type application/json to the calling application 这与mime-type application / json返回给调用应用程序

The following code is the HTML snippet which I thought would make a call to get the data and display it. 以下代码是HTML代码段,我认为该代码段将调用以获取数据并显示它。

            <paper-material elevation="1">
                <div id="GPPracticeContainer">
                    GP List
                    {{data}}
                    <template is="dom-repeat" items="{{data}}"
                        <p>{{item.Name}}</p>
                    </template>

                </div>
            </paper-material>
        </paper-header-panel>
        <iron-ajax auto id="GPCollection" 
                   url="/GPPractices.ashx" 
                   handle-as="json" 
                   last-response="{{data}}"
                   on-response="handleGPCollection">

        </iron-ajax>

and finally the javascript 最后是JavaScript

<script>

    function handleKeyPress(e) {
        if (e.keyCode == 13) {
            alert('off to search for something!');
        }
    };

    Polymer({
        is: "practice-list",
        hideSearch: {
            type: Boolean,
            value: false
        },
        handleGPCollection: function(request) {
            alert('GP Practices collected ' + request);
        },
        ready: function () {
            this.hideSearch = true;
            this.$.searchText.keyup(function (e) {
                alert('off to search for something!');
            });
        },
        srchandler: function () {
            // search for contents of search box is showing, otherwise show it.
            if (!this.hideSearch)
            {
                alert('off to search for something!');
            }
            else {
                this.hideSearch = !this.hideSearch;
                if (!this.hideSearch) {
                    this.$.searchText.focus();
                }
            }
        }
    });

</script>

Trouble is although the alert box appears showing the data has been read - and returns Object CustomEvent No data appears. 麻烦的是,尽管出现警告框,表明已读取数据-并返回Object CustomEvent没有数据。

anyone know how I can 任何人都知道我能

a) Find out what is going wrong b) Get it to display say the Name of each practice a)查明出了什么问题b)让它显示每个练习的名称

Thanks 谢谢

I am missing the closing'>' of the template. 我缺少模板的结尾'>'。 It should read 它应该读

<template is="dom-repeat" items="{{data}}">
    <p><span>{{item.PracticeCode}}</span> - <span>{{item.Name}}</span></p>
</template>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM