0

I have the following nested dom-repeat:

<firebase-query
  id="query"
  path="[[path]]"
  data="{{parentItems}}"
  app-name="myApp">
</firebase-query>

<template is="dom-repeat"
            items="{{parentItems}}"
            as="parentItem">
    <template is="dom-repeat" items="{{_toArray(parentItem)}}">
      <div>{{item.details}} </div>          
    </template>
 </template>

When items are added/removed from parentItems, the nested child dom-repeat template is not re-rendering i.e. _toArray() is not called. Is this behaviour expected? How do I ensure that when parentItems changes, the nested template will also be updated? Thanks.

user3240644
  • 2,211
  • 2
  • 24
  • 35

1 Answers1

2

I don't have the details of how you add something in the parentItems property, but i assume you do something like this

this.parentItems.push(something)

Polymer won't see the array change in that case, try to use the polymer push instead,

this.push('parentItems', something)

It will push it in the array, and notify polymer binding to update the view.

Arfost
  • 506
  • 1
  • 4
  • 16
  • Thanks for responding. i'm using firebase-query to update parentItems. I've updated my question to reflect this. – user3240644 Jan 11 '17 at 12:32
  • Ok, normally firebase-query is doing the right calls for the polymer databinding, so it must be something else. I can't test with firebase for now, but I'll try it later. – Arfost Jan 11 '17 at 13:11
  • Right, I think this is what is happening. parentItems is an array of objects. I had expected that when the object mutates, it'll trigger the nested dom-repeat. In this case, what should I do to ensure that the nested dom-repeat is triggered when the object in the array changes? – user3240644 Jan 11 '17 at 14:09
  • It can be a tricky one, the first thing I'd try would be to add an observe="object object.prop" attribute to my dom-repeat and watch the path of the values that can change. If this don't work, I think I'll need more code too help :) – Arfost Jan 11 '17 at 14:27
  • Thanks. Yeah its tricky cause the keys are random firebase unique ids... :( – user3240644 Jan 11 '17 at 14:54