How to reload a dom-repeat template on update to localstorage?

420 views
Skip to first unread message

howard...@gmail.com

unread,
Sep 18, 2015, 8:39:39 PM9/18/15
to Polymer
I have this:

   <template id="repeat" is="dom-repeat" items="[[model]]" as="day">
       
<component model="[[day]]"></component>
   
</template>


It's recieving model from a iron-local-storage load. When I push something to my localstorage using localStorage.setItem, I want this dom-repeat to update and display the new item I pushed. 

Right now it only appears AFTER I refresh the page, because it reloads everything from local storage. 

I tried using this.$.repeat.render(); but that didn't work. I want the dom-repeat to display the new object instantly without having to refresh the page. 

Is this possible?

Thanks!

Message has been deleted

Aleks Totic

unread,
Sep 22, 2015, 11:49:06 PM9/22/15
to Polymer, howard...@gmail.com
The problem is that iron-localstorage does not reflect updates you make with localstorage.setItem. If you are using DOM APIs, you need to call iron-localstorage.reload to load the new value.

localstorage is not a global.

Aleks

howard...@gmail.com

unread,
Sep 23, 2015, 5:59:07 PM9/23/15
to Polymer, howard...@gmail.com
This works. Thank you!
Reply all
Reply to author
Forward
0 new messages