Skip to content
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

Using scoped models impacts 2-way property binding #220

Closed
sorvell opened this issue Jul 26, 2013 · 1 comment
Closed

Using scoped models impacts 2-way property binding #220

sorvell opened this issue Jul 26, 2013 · 1 comment
Assignees

Comments

@sorvell
Copy link
Contributor

sorvell commented Jul 26, 2013

Given this type of usage:

<polymer-element name="x-thing">
  <template>
    <template repeat="{{user in users}}">
      <x-item manager="{{manager}}"></x-item>
    </template>
  </template>
  <script>
    Polymer('x-thing', {
      ready: function() {
        this.manager = {name: "Bob"};
      }
    });
  </script>
</polymer-element>

The expectation here is that x-thing's manager property is bound directly to x-item's manager property.

However, the use of the scoped model {{user in users}} makes the binding 1-way instead of 2-way. The model used to populate x-item is no longer x-thing but instead an object with a user property an x-thing as its prototype. Therefore, when x-item sets manager is does not change the value in x-thing.

This behavior can be worked around by setting a reference to the element inside itself like this:

<polymer-element name="x-thing">
  <template>
    <template repeat="{{user in users}}">
      <x-item manager="{{self.manager}}"></x-item>
    </template>
  </template>
  <script>
    Polymer('x-thing', {
      ready: function() {
        this.self = this;
        this.manager = {name: "Bob"};
      }
    });
  </script>
</polymer-element>
@ghost ghost assigned sorvell Sep 25, 2013
@sorvell
Copy link
Contributor Author

sorvell commented Aug 13, 2014

This has been fixed.

@sorvell sorvell closed this as completed Aug 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant