Help with dynamically setting items in iron-list?

297 views
Skip to first unread message

Kujako

unread,
Jul 23, 2015, 5:50:43 PM7/23/15
to Polymer
Given the following code...
<dom-module id="fnord-element">
  <template>
    <iron-list items="[[myItems]]" as="item">
      <template>
        <div class="item">[[item.name]]</div>
      </template>
    </iron-list>
  </template>
  <script>
    Polymer({
      is:'fnord-element',
      properties: {
        myItems: {
        type: Array,
        notify: true
        }
      },
      addItem: function(item) {
        //this.push("myItems", {"name":item});
        this.myItems=[{name:item}];
        alert(this.myItems[0].name);
        //alert(item);
      },
      ready: function() {
        //alert('fnord');
        this.myItems=[{name:"One"},{name:"Two"}];
      }
    });
  </script>
</dom-module>
<fnord-element id="fnord"></fnord-element>
<paper-button raised onclick="document.querySelector('#fnord').addItem('John Doe');">Test</paper-button>

I can access and update the myItems array and see values being set to it via the alert() method call, but no items are actually displayed from the ready() or addItem() calls.

Clearly I'm missing something fundamental, but I'm at a bit of a loss as to what it is.

Kujako

unread,
Jul 23, 2015, 11:42:56 PM7/23/15
to Polymer, jfi...@vintara.com
Hum... looks like the above code works just fine. Some other element in my app must be hiding the list or conflicting with something.
Reply all
Reply to author
Forward
0 new messages