Last active
February 26, 2016 19:24
-
-
Save indolering/cae1ffa7cf4c436d5abd to your computer and use it in GitHub Desktop.
This file contains 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="../polymer/polymer.html"> | |
<link rel="import" href="../iron-list/iron-list.html"> | |
<!--<link rel="import" href="child-element.html">--> | |
<dom-module id="seed-element"> | |
<template> | |
<style> | |
:host { | |
display: block; | |
box-sizing: border-box; | |
} | |
iron-list { | |
height: 100px; | |
width: 100px; | |
} | |
/*Commenting this out fixes the issue*/ | |
.child { | |
display: block; | |
} | |
</style> | |
<i>Note: enter a search and clear it to kick iron-list/data-binding into working.</i> | |
<div> | |
<input value="{{search::input}}" type="search" placeholder="search for world"> | |
</div> | |
<iron-list items="[[filter(records, search)]]"> | |
<template> | |
<div class="child"> | |
<span>[[item]]</span> | |
</div> | |
</template> | |
</iron-list> | |
</template> | |
<script> | |
Polymer({ | |
is: 'seed-element', | |
properties: { | |
records: { | |
type: Array, | |
value: function(){ | |
return [ | |
"hello", | |
"world" | |
] | |
} | |
}, | |
search: "" | |
}, | |
ready: function() { | |
}, | |
filter: function(records, search){ | |
search = search.trim(); | |
var matching = []; | |
this.records.forEach(function(record){ | |
if(search == "" || record.indexOf(search) > -1){ | |
matching.push(record); | |
} | |
}.bind(this)); | |
return matching; | |
} | |
}); | |
</script> | |
</dom-module> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment