Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Inside a polymer element, clears existing data #51

Open
Quantumplation opened this issue Apr 18, 2015 · 4 comments
Open

Inside a polymer element, clears existing data #51

Quantumplation opened this issue Apr 18, 2015 · 4 comments

Comments

@Quantumplation
Copy link

I'm not sure if this is actually an issue, or just me misusing the element, but when placed inside another polymer element, as so:

<polymer-element name="test">
    <template>
        <div>
            <firebase-element id="base" data="{{data}}" location="..."></firebase-element>
        </div>
    </template>
    <script>
        Polymer({
        })
    </script>
</polymer-element>

the initial data binding commits a value of null to firebase. I've tried it both with and without specifying a data element in the Polymer function.

@VandeurenGlenn
Copy link

You're misusing it, what you have now is data binded to the firebase-element 'data' attribute, so whatever value data contains, it is written to firebase...

This is how I usually set my data on firebase.

<polymer-element name="test" attributes="data">
  <template>
    <div>
      <firebase-element id="base" location="..."></firebase-element>
    </div>
    <input value="{{data}}"></input>
  </template>
  <script>
    Polymer({
      data: null,

      dataChanged: function() {
          if(this.data !== null) {
              this.$.base.data = this.data;
          } else {
          // 'data' = null
          }
      }
    })
  </script>
</polymer-element>

@Quantumplation
Copy link
Author

That's what I gathered, but it is different behavior from placing it in a <template is="auto-binding"> (firebase fills in the value right away, rather than committing null back to firebase), which is rather misleading. Should this be documented somewhere?

@VandeurenGlenn
Copy link

@Quantumplation I'm not sure, I'll need to make some time to test this, butt I'm suspecting the same behavior.

@VandeurenGlenn
Copy link

@Quantumplation It does the same for when auto-binding, maybe its version related ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants