Last active
December 15, 2015 06:19
-
-
Save vadimdemedes/5215659 to your computer and use it in GitHub Desktop.
Loading data
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
<script class="asset-template" type="application/x-template"> | |
<div class="image"> | |
<img src="{{ url }}"> | |
<span class="username">By {{ user.username }}</span> | |
</div> | |
</script> | |
<script class="assets-template" type="application/x-template" | |
<div class="assets"> | |
<!-- Assets will be rendered here --> | |
</div> | |
</script> |
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
var AssetView = Chute.View.extend({ | |
template: Chute.Utils.template('script.asset-template') | |
// if container property is not specified, item views will be inserted into parent element | |
}); | |
var AssetCollectionView = Chute.CollectionView.extend({ | |
template: Chute.Utils.template('script.assets-template'), | |
itemView: AssetView // specifying a view for each data item | |
}); | |
var assets = new Chute.API.Assets(null, { album: 'ALBUM_SHORTCUT' }); | |
var view = new AssetCollectionView({ | |
container: 'div.assets-view', | |
collection: assets | |
}); | |
view.render(); | |
assets.fetch(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment