-
Notifications
You must be signed in to change notification settings - Fork 20
changes to data model not detected #2
Comments
One workaround I found is to append the original object to the physical object inside pushItemData method (https://github.com/Polymer/core-list/blob/master/core-list.html#L211) Like this:
And then bind properties related to the original object like this: <core-list data="{{data}}" height="80">
<template>
<div class="item {{ {selected: selected} | tokenList }}"> {{_.name}} <br />
<p><i>{{_.description}}</i></p>
</div>
</template>
</core-list> Using this approach now you can see changes to the original data. |
2-way binding will be resolved in core-list improvements currently on work-in-progress branch https://github.com/Polymer/core-list/tree/2way-improved. It will involve a minor change to the API (bind to |
@kevinpschaaf When do you think this will be fixed and released? I though the sync attribute would take care of keeping the model and list data in sync but just found out this issue so that seems not to be the case. I'll be waiting and needing the fix... Thanks. |
Since the fix for this introduces a breaking change to the API, before we release it I am trying to get far enough through the implementations of other high-priority features that could also impact API (particularly variable-height, grouping, and grid layout) to at least understand what other API changes those might drive, so that we only break the API once. That said, I can probably merge the 2-way binding fixes separate from the other features once I get a good feeling for the final API's -- rough estimate for getting to that point is another a week, maybe a bit longer. |
Thanks for the update. |
core-list creates a shallow copy of each item's data, so it can recycle the DOM node when it scrolls out. One issue is it never observes the original data items, so changes to them aren't detected. For example, modify demo.html to have this "ready" method:
until you scroll, items don't update.
This could be fixed by either a periodic dirty-check or by Object.observe on the original model items and proxy changes back to the shallow copies. Personally I'd lean towards the second approach (using O.o via observe-js).
Of course, if TemplateBinding gets built-in DOM recycling, this will be a non-issue.
The text was updated successfully, but these errors were encountered: