Skip to content

Instantly share code, notes, and snippets.

@citruslee
Created November 8, 2014 23:02
Show Gist options
  • Save citruslee/d6b3836f37442e7d59db to your computer and use it in GitHub Desktop.
Save citruslee/d6b3836f37442e7d59db to your computer and use it in GitHub Desktop.
designer
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="greeting-tag">
<template>
<style>
</style>
<ul>
<template repeat="{{s in dataSet}}"></template>
</ul>
<button type="submit" willvalidate on-click="{{ updateModel }}">Update model</button>
</template>
<script>
Polymer({
ready: function () {
//alert(httpGet('http://freecharging.sk/api/getNearestUnits/win/47.9941484/17/0'));
this.dataSet = JSON.parse(httpGet('http://freecharging.sk/api/getNearestUnits/win/47.9941484/17/0'));
//alert(this.dataSet);
this.alternates = ['Hello', 'Hola', 'Howdy'];
this.current = 0;
$(".scrollpane").scroll(function() {
var $this = $(this);
var $results = $("#results");
if (!$results.data("loading")) {
if ($this.scrollTop() + $this.height() == $results.height()) {
this.dataSet.append(JSON.parse(httpGet('http://freecharging.sk/api/getNearestUnits/win/47.9941484/17/0')));
}
}
});
},
updateModel: function () {
this.current = (this.current + 1) % this.alternates.length;
this.dataSet[0].unitname = this.alternates[this.current];
}
});
</script>
</polymer-element>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment