Last active
March 15, 2016 12:38
-
-
Save justinribeiro/04fd25cf9ef82ed51113 to your computer and use it in GitHub Desktop.
Basic updating with custom Polymer element, firebase-collection, and firebase-document
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="import" href="bower_components/polymer/polymer.html"> | |
<link rel="import" href="bower_components/firebase-element/firebase-document.html"> | |
<dom-element id="edit-name"> | |
<template> | |
<style> | |
:host { | |
display: block; | |
padding: 1em; | |
} | |
input { | |
width: 50%; | |
} | |
</style> | |
<firebase-document | |
location="{{target}}" | |
data="{{data}}" | |
log> | |
</firebase-document> | |
<input type="text" value="{{data.person::input}}"> | |
</template> | |
<script> | |
(function() { | |
Polymer({ | |
is: 'edit-name', | |
properties: { | |
record: String, | |
target: { | |
type: String, | |
computed: 'firebaseRef(record)' | |
} | |
}, | |
firebaseRef: function(record) { | |
return "https://polymer-ele-testing.firebaseio.com/people/" + record; | |
} | |
}); | |
})(); | |
</script> | |
</dom-element> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Firebase + Polymer + Updating</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta name="apple-mobile-web-app-capable" content="yes"> | |
<meta name="mobile-web-app-capable" content="yes"> | |
<script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script> | |
<link rel="import" href="bower_components/firebase-element/firebase-collection.html"> | |
<link rel="import" href="edit-name.html"> | |
<style type="text/css"> | |
body { | |
font-family: Roboto, Helvetica, sans-serif; | |
} | |
</style> | |
</head> | |
<body> | |
<template is="dom-bind"> | |
<firebase-collection | |
location="https://polymer-ele-testing.firebaseio.com/people" | |
data="{{people}}" log></firebase-collection> | |
<template is="dom-repeat" items="[[people]]" as="person"> | |
<edit-name record="[[person.__firebaseKey__]]"></edit-name> | |
</template> | |
</template> | |
</body> | |
</html> |
Awesome stuff! Very helpful. Thanks for sharing.
👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will help. We have been stuck also.