Reputation: 2949
I've used this.push
in Polymer but now I got error and I can't find what it is due to.
Here's my code:
if (!ui.validation.validateForm(this.$.partnerForm)) return;
var partner = {
name: this.$.partnerName.value,
description: this.$.partnerDescription.value
};
if (!this.eventData.partners) this.eventData.partners = [];
this.push('eventData.partners', partner);
The error is:
Uncaught TypeError: Cannot read property 'length' of undefined
at HTMLTemplateElement._applySplicesArrayOrder (polymer.html:4991)
at HTMLTemplateElement._render (polymer.html:4842)
at Debouncer.complete (polymer-mini.html:2081)
at Debouncer.boundComplete (polymer-mini.html:2058)
at Object._atEndOfMicrotask (polymer-mini.html:2036)
at MutationObserver.window.MutationObserver.observe.characterData
When I debug using console.log(this.eventData.partners)
data is there, but after that it gives that error. What might be wrong with this push? Thanks.
Upvotes: 1
Views: 421
Reputation: 2949
I found the problem. I have been used this:
if (!this.eventData.partners) this.eventData.partners = [];
I changed it in the following way and it's working now:
if (!this.eventData.partners) this.set('eventData.partners', []);
This is Polymer specific issue.
Upvotes: 1