Created
April 4, 2013 20:15
-
-
Save vadimdemedes/5313986 to your computer and use it in GitHub Desktop.
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
<script src="//cdn.getchute.com/v3/chute.min.js" data-load="view"></script> | |
<style> /* Some basic styling for a grid */ | |
div.assets { | |
overflow:hidden; | |
} | |
div.asset { | |
float:left; | |
margin:10px; | |
} | |
div.asset img { | |
width:180px; | |
height:180px; | |
} | |
</style> | |
<!-- Template for a container element --> | |
<script class="container-template" type="application/x-template"> | |
<div class="assets"></div> | |
</script> | |
<!-- Template for an item element --> | |
<script class="item-template" type="application/x-template"> | |
<div class="asset"> | |
<img src="{{ asset.url }}/200x200"> | |
</div> | |
</script> | |
<script> | |
Chute.ready(function(){ // run after view was loaded | |
var GridItemView = Chute.View.extend({ // view for a single data item | |
template: 'script.item-template' // specifying template via selector | |
}); | |
var GridView = Chute.CollectionView.extend({ // view for a collection of data items | |
template: 'script.container-template', | |
itemView: GridItemView // specifying item view for a collection | |
}); | |
var grid = new GridView({ | |
container: 'div.grid', // set div.grid as a container for a view | |
data: new Chute.API.Assets({ album: '9IZukfpi' }).toData() // specify a data set for a collection view | |
}); | |
}); | |
</script> | |
<div class="grid"></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment