Skip to content

Instantly share code, notes, and snippets.

@rafagarcia
Last active February 28, 2017 08:59
Show Gist options
  • Select an option

  • Save rafagarcia/9f690d42f472bd7f84bc27d0a52e708c to your computer and use it in GitHub Desktop.

Select an option

Save rafagarcia/9f690d42f472bd7f84bc27d0a52e708c to your computer and use it in GitHub Desktop.
Observer example inside list.html
<script>
Polymer({
is: 'polymaiap-list',
properties: {
data: {
type: Object,
observer: '_handleResponse'
},
selectedItem: {
type: Object,
observer: '_handleSelection'
}
},
//Once data is received via ajax and stored in the data property, loader is hidden and employees list is shown
_handleResponse: function() {
this.$.loader.style.display = 'none';
this.$.listWrapper.style.display = 'block';
},
_handleSelection: function() {
if (this.selectedItem) {
this.fire('selectedItem', this.selectedItem);
// Deselect previous selected item to ensure navigation between list and detail
this.$$('iron-list').deselectItem(this.selectedItem);
}
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment