-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setting individual array elements not working #1854
Comments
Looks to me like |
Help us, @kevinpschaaf, you're our only hope! |
Re-running the plunkr sample against your branch, it looks like the dom-repeat is now registering correctly, but the static bindings are still wrong: |
@pvmart As I mentioned on #1839, the root cause of that issue plays into what you were seeing here. However, I didn't quite grok that you were binding directly to array indicies in your example. The binding system does not support updating bindings to explicitly de-referenced array elements like this (what you're seeing is a side-effect of how we uniquely key array elements and send path notifications of which keys change, rather than which indicies get updated for better performance, so the However, the binding/observation system exposes enough hooks for you to do this manually (i.e. what we're lacking in the system is just the ability to set up what I describe below implicitly based on inferring that you are binding to array indicies, but it's fully possible to wire it up yourself). You can write bindings that use an inline function to help dereference the array and keep the value in sync when the array mutates, like arrayItem: function(change, idx, path) {
return this.get(path, change.base[idx]);
} The Your code would then look like this: <div>[0] <span>[[arrayItem(test.*, 0, 'value')]]</span></div>
<div>[1] <span>[[arrayItem(test.*, 1, 'value')]]</span></div>
<div>[2] <span>[[arrayItem(test.*, 2, 'value')]]</span></div> I updated your JSBin below using the #1855 branch, so once that fix lands you should be able to use this workaround. |
Thanks @kevinpschaaf -- it looks like I've got this wrong in the docs. https://www.polymer-project.org/1.0/docs/devguide/data-binding.html#path-binding I'm somewhat confused by the distinction between keys and indices here, and exactly how we should communicate this distinction. But it sounds like the short version is:
|
With http://jsbin.com/kiwacasiju/1/edit?html,output Fix: https://github.com/pvmart/polymer/pull/1/files |
Thanks-- I'll take a look at that. There were a few other issues with the branch that I'm working out, so it will be a little longer. |
Testing:
results in dom-repeat to be updated now correctly.
results in list.1 and .2 to stay changed, but list.0 is reset to the original value. |
OK, might be this
path.0 works if you change
|
nothing here works anymore |
@Alvarz Do you expect any response to your comment? |
@zoechi hi! excuse me that behavior it's just i was really really mad because i'm getting big issues with data binding and all the post or guides or answer only work with version 0.5, i really dont expect any answer and again I really apologize for my behavior. |
@Alvarz :D I suggest asking on StackOverflow about your actual problem, ideally with a Plunker/JSBin that reproduces the issue. |
@zoechi Thanks I will do it! |
Binding specified by path eq [[test.0.value]] or dom-repeat have nothing in common with actual data in model.
Given:
results in
http://plnkr.co/edit/RFWLVhQ5yZ5E4sQYpLJG?p=preview
The text was updated successfully, but these errors were encountered: