Skip to content

Instantly share code, notes, and snippets.

@udarapathmin
Created October 31, 2014 03:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save udarapathmin/a7cdfc156b2942362fb8 to your computer and use it in GitHub Desktop.
Save udarapathmin/a7cdfc156b2942362fb8 to your computer and use it in GitHub Desktop.
designer
<link rel="import" href="../core-ajax/core-ajax.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
box-sizing: border-box;
}
#core_card {
position: absolute;
width: 390px;
height: 120px;
border-top-left-radius: 2px;
border-top-right-radius: 2px;
border-bottom-right-radius: 2px;
border-bottom-left-radius: 2px;
box-shadow: rgba(0, 0, 0, 0.0980392) 0px 2px 4px, rgba(0, 0, 0, 0.0980392) 0px 0px 3px;
left: 280px;
top: 110px;
background-color: rgb(255, 255, 255);
}
</style>
<core-ajax url="http://tdslanka.com/tns/api/example/items/format/json" handleas="json" auto id="ajax" on-core-response="{{ postsLoaded }}" hidden>
</core-ajax>
<template repeat="{{post in posts}}"></template>
</template>
<script>
Polymer({
created: function () {
this.posts = [];
},
postsLoaded: function () {
// Make a copy of the loaded data
this.posts = this.$.ajax.response.slice(0);
},
setFavorite: function (uid, isFavorite) {
// no service backend, just log the change
console.log('Favorite changed: ' + id + ", now: " + isFavorite);
}
});
</script>
</polymer-element>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment