Last active
December 22, 2015 22:39
-
-
Save martinkadlec0/6541778 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
| <!DOCTYPE html> | |
| <html lang="en" dir="ltr"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title></title> | |
| <script src="scripts/libs/jquery.min.js"></script> | |
| <script src="scripts/libs/underscore.min.js"></script> | |
| <script src="scripts/libs/backbone.min.js"></script> | |
| <script src="scripts/libs/backbone.marionette.min.js"></script> | |
| <script> | |
| $(function() { | |
| var Marionette = Backbone.Marionette; | |
| var Item = Backbone.Model.extend({ | |
| defaults: { | |
| 'name': '<no name>' | |
| } | |
| }); | |
| var items = new (Backbone.Collection.extend({ | |
| model: Item | |
| })); | |
| var ItemView = Marionette.ItemView.extend({ | |
| template: '#template-item' | |
| }); | |
| var CollectionView = Marionette.CollectionView.extend({ | |
| itemView: ItemView, | |
| initialize: function() { | |
| items.add({ name: 'Tom' }); | |
| items.add({ name: 'John' }); | |
| items.add({ name: 'Erick' }); | |
| } | |
| }); | |
| var collView = new CollectionView({ collection: items }); | |
| var Layout = Marionette.Layout.extend({ | |
| template: '#template-layout', | |
| regions: { | |
| coll: '#collection' | |
| } | |
| }); | |
| layout = new Layout(); | |
| layout.coll.show(collView); | |
| var app = new Marionette.Application(); | |
| app.addRegions({ | |
| 'main': '#main' | |
| }); | |
| app.main.show(layout); | |
| }); | |
| </script> | |
| </head> | |
| <body> | |
| <section id="main"> | |
| </section> | |
| <script id="template-item" type="text/template"> | |
| Name: <%= name %> | |
| </script> | |
| <script id="template-layout" type="text/template"> | |
| <h3>List:</h3> | |
| <div id="collection"> | |
| </div> | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment