firebase-element
firebase-element copied to clipboard
Upon 'add' i get Uncaught TypeError: Cannot read property 'ref' of undefined
trafficstars
I am able to successfully log in and get the token back but then when i try to add data i get exception, can you guys help? Below is my code:
<firebase-auth id="fbLogin" provider="anonymous" location="https://xxx.firebaseio.com" user="{{fbUser}}" statusKnown="{{statusKnown}}"></firebase-auth>
<firebase-collection id="fbLanding" location="https://xxx.firebaseio.com/" dataReady="{{userReady}}"></firebase-collection>
<div class="form-section">
<gold-email-input required error-message="Please enter a valid email" label="Email contact" value="{{email}}" name="email" id="email" ></gold-email-input>
<paper-button type="submit" name="submit" raised on-click="buttonClick">Notify Me!</paper-button> </div>
<script>
Polymer({
is: 'landing-page',
ready: function() {
window.addEventListener('offline', function() {
Firebase.goOffline();
});
window.addEventListener('online', function() {
Firebase.goOnline();
});
},
buttonClick: function() {
this.$.fbLogin.login();
this.$.fbLanding.add({
timeStamp:Firebase.ServerValue.TIMESTAMP,
email:this.$.email.value
});
},
listeners: {
'firebase-child-added': 'fireBaseResponse'
},
fireBaseResponse: function(event) {
var sessionId = event.key();
if (!sessionId){
this.$.toast1.text="Ah Oh! something went wrong";
this.$.toast1.toggleClass('errorClass', true);
}
else{
this.$.toast1.toggleClass('errorClass', false);
this.$.toast1.text="Thanks!";
}
this.$.toast1.show();
}
});
</script>
The exception is at https://github.com/GoogleWebComponents/firebase-element/blob/master/firebase-collection.html#L227
play with using both document and collection ;
http://jsbin.com/lokegu/edit?html,output
@marcus7777 thanks for your reply. You are using firebase push operation, i wanted to use the add method as mentioned in firebase-collection document to add data. see https://elements.polymer-project.org/elements/firebase-element?active=firebase-collection